本文整理汇总了Python中elementtree.ElementTree.SubElement.tail方法的典型用法代码示例。如果您正苦于以下问题:Python SubElement.tail方法的具体用法?Python SubElement.tail怎么用?Python SubElement.tail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elementtree.ElementTree.SubElement
的用法示例。
在下文中一共展示了SubElement.tail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addGraphonesToLexicon
# 需要导入模块: from elementtree.ElementTree import SubElement [as 别名]
# 或者: from elementtree.ElementTree.SubElement import tail [as 别名]
def addGraphonesToLexicon(xml, graphones):
lexicon = xml.getroot()
for letters, phonemes in graphones:
lemma = SubElement(lexicon, 'lemma')
lemma.text = '\n '
orth = SubElement(lemma, 'orth')
orth.text = '_' + ''.join(letters) + '_'
orth.tail = '\n '
phon = SubElement(lemma, 'phon')
phon.text = ' '.join(phonemes)
phon.tail = '\n '
synt = SubElement(lemma, 'synt')
SubElement(synt, 'tok').text = lmToken(letters, phonemes)
synt.tail = '\n'
# synt.tail = '\n '
# eval = SubElement(lemma, 'eval')
# SubElement(eval, 'tok').text = '[UNKNOWN]'
# eval.tail = '\n'
lemma.tail = '\n'
示例2: changeSyntaticToPhonetic
# 需要导入模块: from elementtree.ElementTree import SubElement [as 别名]
# 或者: from elementtree.ElementTree.SubElement import tail [as 别名]
def changeSyntaticToPhonetic(xml):
lexicon = xml.getroot()
for lemma in lexicon.getiterator('lemma'):
if lemma.get('special'): continue
phon = lemma.find('phon')
if phon is not None:
phon = phon.text.split()
phon.append('#1')
synt = lemma.find('synt')
if synt is None:
synt = SubElement(lemma, 'synt')
else:
synt.clear()
synt.tail = '\n '
if phon:
for ph in phon:
SubElement(synt, 'tok').text = ph