今天早上我意識到,使用字面字串來生成標籤是可行的。不過,這有點像是取巧的做法(hack),因為它依賴於知道 Apertium 會將標籤放在 <> 中,而且我覺得 FlexTrans 使用者真的不應該依賴這種細節。
然而,這意味著,在從輸入串流中提取基本資訊(例如名詞類別)並將其放入字面字串變數(例如 var v_noun_class := string ‘3’)之後,你可以執行類似以下操作:
let var v_gloss = “<”
append var v_gloss “NPx”
append var v_gloss “_”
append var v_gloss var v_noun_class
append var v_gloss “>”
……然後輸出 var v_gloss,結果將正確合成(就像我輸出了字面標籤 NPx_3 一樣)
在我的情況下,這意味著我也可以在另一個變數中生成後綴標籤,只需將 NPx 改為 NSx 即可——這比為每個包含名詞類別資訊及其他內容的輸出詞綴標籤管理一個巨大的 choose when … when … when … 結構要容易得多(也更易讀)。
因此,一方面,這似乎是一個醜陋的取巧做法;另一方面,它允許更優雅、更易讀地生成複雜的詞綴標籤。你們對這種方法有什麼看法?
祝好,bruce
I realised this morning that it is possible to generate tags using literal strings. It is, however, a bit of a hack, because it relies on knowing that Apertium puts tags in <> and it feels to me that the FlexTrans user really shouldn’t be relying on such details.
However, it means that, having extracted basic information from the input stream (like noun class) into a literal string variable (e.g., var v_noun_class := string ‘3’), one can do something like:
let var v_gloss = “<”
append var v_gloss “NPx”
append var v_gloss “_”
append var v_gloss var v_noun_class
append var v_gloss “>”
… and then output var v_gloss and the result will synthesize correctly (just as if I had output the literal tag NPx_3)
In my case, it means I can also generate a suffix tag in a separate variable, just changing NPx to NSx – which is a lot easier (and more readable) than managing a big choose when … when … when … structure for each output affix tag that includes noun class information and something more.
So on the one hand, it seems to be an ugly hack, and on the other, it allows more elegant and readable generation of complicated affix tags. What are your thoughts on this approach?
Cheers, bruce
機器翻譯自 English