Knowledgebase: Usage > Project Management
How to convert a MARTIF termbase to a bilingual glossary (TSV, CSV)
Posted by Péter Botta on 11 October 2012 08:22 AM

To convert a MARTIF termbase to a bilingual glossary (TSV, CSV), you can:

Use Apsic Xbench (http://www.apsic.com/en/products_xbench.html)

Use the following Excel macro:


The following Excel macro will convert your MARTIF file to a simple two-column, source-target-language Excel glossary. While you will lose a lot of the more advanced information that might be contained in the MARTIF file (such as relationships between terms, synonyms, antonyms, definitions, etc.), sometimes, as you and I well know, it's the bare-bones glossary data that counts, and that you will get.

And how to use the macro? Open the Macro dialog in Excel (earlier versions: Tools> Macro; current versions: select Macro on the View or Developer ribbon), enter mtf2xls, select Create, paste the macro and save it, run the macro, select the MARTIF file, convert, and voilà. You might run into problems with some broken special characters, but those should be an easy fix with a couple of quick search-and-replace actions.

-- 
Excel macro for converting martif to xls
--

Sub mtf2xls()

Dim fs, a, strs, rets, langs(10)
Flag = 0
strs = InputBox("path to martif")
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(strs, 1, -2)
j = 0
Do While f.AtEndOfStream <> True
rets = f.ReadLine
lab1:
lgd = Len(rets)

If (Left(rets, 1) = " ") Then
lgk = lgd - 1
rets = Right(rets, lgk)
GoTo lab1
End If

If Left(rets, 10) = "<termEntry" Then
j = j + 1
Cells(j + 1, 1) = j
End If

wh = InStr(rets, "lang=")
If wh <> 0 Then
    wh = wh + 5
    asu = Asc(Mid(rets, wh, 1))
    
 
    we = wh
recog2:
    we = we + 1
        If (Asc(Mid(rets, we, 1)) <> asu) Then
            GoTo recog2
        End If
    lantx = Mid(rets, wh + 1, we - wh - 1)

    If numlan = 0 Then GoTo addlan2
    For k = 1 To numlan
    If lantx = langs(k) Then GoTo knownlan2
    Next k
addlan2:
    numlan = numlan + 1
    k = numlan
    langs(k) = lantx
    Cells(1, k + 1) = lantx
End If

knownlan2:
If Left(rets, 6) = "<term>" Then
    lgd = Len(rets)
    lgk = lgd - 13
    ttr = Mid(rets, 7, lgk)
    Cells(j + 1, k + 1) = ttr
End If

Loop
f.Close
Columns("A:K").AutoFit
End Sub


(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Help Desk Software by Kayako support.memoq.com/index.php?