python len ljust_Python string.ljust方法代码示例
# 需要導入模塊: import string [as 別名]
# 或者: from string import ljust [as 別名]
def process_utterance(self, utt, make_label=True):
utt_data = []
utt_questions = defaultdict(int)
nodelist = utt.xpath(self.config["target_nodes"])
if nodelist == []:
print('WARNING: FeatureDumper\'s target_nodes matches no nodes: %s'%(self.config["target_nodes"]))
for node in nodelist:
self.htk_state_xpath = None ## make sure this is none.
self.start_time_xpath = None
self.end_time_xpath = None
## for phone!:--
node_data, node_questions = self.get_node_context_label(node)
statelist = node.xpath('.//'+self.state_tag)
assert statelist != []
for (i, state) in enumerate(statelist):
state_ix = i + 2
state_node_data = "%s[%s]"%(node_data, state_ix)
start_time = state.attrib.get(self.start_attribute, '_NA_') ## no time at runtime!
end_time = state.attrib.get(self.end_attribute, '_NA_')
if not (start_time=="_NA_" or end_time=="_NA_"):
start_time = string.ljust(str(ms_to_htk(start_time)), 10)
end_time = string.ljust(str(ms_to_htk(end_time)), 10)
state_node_data = "%s %s %s"%(start_time, end_time, state_node_data)
utt_data.append(state_node_data)
##utt_questions.update(node_questions)
## Sum the dictionaries' values:
for question in node_questions:
utt_questions[question]+=node_questions[question]
if make_label:
label_file = utt.get_filename(self.config["output_filetype"])
writelist(utt_data, label_file, uni=True)
return (utt_data, utt_questions) ## for writing utterance-level labels,
## these returned values will be ignored. But these can be used to
## acccumulate questions and features over the whole corpus for
## training (see train() method).
總結
以上是生活随笔為你收集整理的python len ljust_Python string.ljust方法代码示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: struts启动过滤器异常_面试必备:网
- 下一篇: python程序员编辑器_5款Pytho