今天早上我意识到,可以使用字面字符串来生成标签。不过,这有点像是“取巧”的做法,因为它依赖于知道 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