Open tkw1536 opened 10 years ago
@m-iancu I belive this is what we were talking about today. I have implemented this on dev, please test.
@eluzhnica Please also take a look. You should get the exact syntax via "lmh translate --help"
Latest version of dev crashes on lmh translate defeq.en.tex al
with:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/lmh_core/__init__.py", line 289, in main
run_lmh(install)
File "/usr/local/lib/python2.7/dist-packages/lmh_core/__init__.py", line 88, in run_lmh
s.main()
File "/var/data/localmh/bin/lmh", line 11, in main
lmh.run(sys.argv[1:])
File "/var/data/localmh/bin/../lmh/__init__.py", line 128, in run
if main(argv):
File "/var/data/localmh/bin/../lmh/__init__.py", line 122, in main
return submods[args.action].do(args)
File "/var/data/localmh/bin/../lmh/commands/translate.py", line 82, in do
ret = transmod(ofn[0], ofn[1], lang, pre_terms = args.terms) and ret
File "/var/data/localmh/bin/../lmh/lib/modules/translate.py", line 217, in transmod
content = re.sub(r"\\ttl\{([^\}]*)\}", replacer2, content)
File "/usr/lib/python2.7/re.py", line 151, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "/var/data/localmh/bin/../lmh/lib/modules/translate.py", line 215, in replacer2
return "\\ttl{"+term+"}"
TypeError: cannot concatenate 'str' and 'tuple' objects
lmh seems to have crashed with <type 'exceptions.TypeError'>
a report will be generated in
lmh translate defeq.en.tex al --terms test.json
with a dummy json does the same thing.
Doesn't crash for me anymore so that's good. Didn't test any further though (I didn't have a good json file to use).
Doesn't crash anymore. In most of the cases it works, but it looks like it's not working for terms that contain "-" in them. For instance, in defeq.en.tex, definitional-equation should be translated to definitionale-Gleichung in German. Here is a test json.
{"en" : {"de" : {"structure" : "%DStruktur", "equal" : "gleich", "definiens" : "Definiens", "definitional-equation" : "definitionale-Gleichung", "approximately-equal" : "annährend-gleich", "definiendum" : "Definiendum", "component" : "Komponenten"}}, "de" : {"en" : {"Komponenten" : "component", "Definiens" : "definiens", "annährend-gleich" : "approximately-equal", "Definiendum" : "definiendum", "gleich" : "equal", "definitionale-Gleichung" : "definitional-equation", "%DStruktur" : "structure"}}}
@eluzhnica, Unrelated to your report but the %D from e.g. from Struktur shouldn't be there. You should be careful how you print the delimiters to get not the internal encoding but the content that they encode (i.e. use .text instead of .toString).
Currently,
lmh translate generated-subring.en.tex de
translatesinto
This can be improved given that
ring.en.tex
contains\defi{ring}
andring.en.tex
contains\def[ring]{Ring}
, which induces the translation mappingring-->Ring
, with which we can improve the translation toand thus reduce the translation effort by a third.
I think that the pre-translation should be done in collaboration between between lmh and MMT, where MMT computes the translation mapping for a given glossary component (we kwow all the
\gimport
) andlmh
applies it. So @m-iancu should help, maybe Enxhell as well.