我认为问题在于 Paratext 的 XML 指定了什么以及没有指定什么。它指定了文本块、gloss-id(交叉引用 Lexicon.xml 文件)以及原始文本在输入流某种表示中的位置。它不保留出现顺序。节也不是按顺序排列的。
给定的单词或短语可能被注释为单词或词干和语素(当然带有不同的注释),而判断哪个同形异义词是哪个或用户期望哪种级别的注释的唯一方法是通过位置数据。注释文件似乎忽略大小写、标点和 SFM 标记,可能还有其他东西。
因此,如果注释文件与输入匹配,那么假设 Martin 理解了 Paratext 在其内部文件表示中计算字符的未记录方式,那么正确的做法是按位置切出单词/短语单元并用注释替换,可能进行适当的大小写转换。
如果节已更改,则不起作用。如果文件的内部表示是错误的,则不起作用。
任何无约束的搜索和替换都会在异体词上产生错误匹配,因此不能将其用作通用方法。可以进行一些猜测,例如寻找模糊匹配,在单词间隙处断开,加减几个字符。这将花费相当大量的程序员时间,但可能会出现问题。如果由于有人在节中重新排列了单词而导致间距发生变化,偏移 3 个字符的异体词可能不是同一个单词。例如,Romani 有相当自由的词序:
O Del te del tut haro
(the) God SUBJ give you grace
"May God give you grace"
对比
Te del o Del tut haro
SUBJ give (the) God you grace
"May God give you grace"
PTXprint 无法进入语言的语法规则。甚至 Paratext 也不记得/询问事物是什么词性。获取可靠逐行对照数据的唯一可靠方式是用户批准注释。
The problem is, I believe, what Paratext’s XML specifies and what it doesn’t. It specifies chunk of text, gloss-id (cross-referencing the Lexicon.xml file) and the position of the original text in some representatoin of the input stream. It does not preserve the order of occurrence. The verses are not in sequence, either.
A given word or phrase may be glossed as word(s) or stem and morphemes, (of course with different glosses) and the only way to tell which homograph is which or which level of glossing the user expects is via the positioning data. The glossing file seems to ignore case, punctuation and SFM marks, and probably other things too.
Thus if the glossing file matches the input, then assuming that Martin has understood the undocumented way in which Paratext counts characters in its internal representation of the file, then the right thing to do is cut out the word/phrase unit by position and replace with the gloss, possibly doing some case transposition as appropriate.
If the verse has changed, then that doesn’t work. If the internal representation of the file is wrong, then it doesn’t work.
Any unconstrained search and replace is going to get false matches on homographs, so that can’t be used as a general approach. There could be some guessing done, looking for fuzzy-matches plus or minus a few characters, breaking at word-gaps, for instance. That would cost a fairly large investment of programmer time, but there could be problems. If the spacing has changed because someone has reordered the words in the verse, the homograph offset by 3 characters might not be the same word. E.g. Romani has fairly free word order:
O Del te del tut haro
(the) God SUBJ give you grace
"May God give you grace"
vs
Te del o Del tut haro
SUBJ give (the) God you grace
"May God give you grace"
PTXprint can’t go into the linguistics rules of the language. Not even Paratext remembers / asks what parts of speech things are. The only reliable way to get trustworthy interlinear data is for the user to approve glosses.
机器翻译自 English