当前位置: 首页>>代码示例>>Python>>正文


Python Tree.split方法代码示例

本文整理汇总了Python中nltk.tree.Tree.split方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.split方法的具体用法?Python Tree.split怎么用?Python Tree.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nltk.tree.Tree的用法示例。


在下文中一共展示了Tree.split方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from nltk.tree import Tree [as 别名]
# 或者: from nltk.tree.Tree import split [as 别名]
 def __init__(self, row, transcript_metadata):
     """
     Arguments:
     row (list) -- a row from one of the corpus CSV files
     transcript_metadata (dict) -- a Metadata value based on the current conversation_no
     """        
     ##################################################
     # Utterance data:
     for i in xrange(len(Utterance.header)):
         att_name = Utterance.header[i]
         row_value = None
         if i < len(row):                
             row_value = row[i].strip()
         # Special handling of non-string values.
         if att_name == "trees":
             # if row_value: row_value = map(Tree, row_value.split("|||"))
             if row_value: row_value = Tree(None, row_value.split("|||"))
             else: row_value = []
         elif att_name == "ptb_treenumbers":
             if row_value: row_value = map(int, row_value.split("|||"))
             else: row_value = []
         elif att_name == 'act_tag':
             # I thought these conjoined tags were meant to be split.
             # The docs suggest that they are single tags, thought,
             # so skip this conditional and let it be treated as a str.
             # row_value = re.split(r"\s*[,;]\s*", row_value)
             # `` Transcription errors (typos, obvious mistranscriptions) are marked with a "*" after the discourse tag.''
             # These are removed for this version.
             row_value = row_value.replace("*", "")
         elif att_name in ('conversation_no', 'transcript_index', 'utterance_index', 'subutterance_index'):
             row_value = int(row_value)                
         # Add the attribute.
         setattr(self, att_name, row_value)
     ##################################################
     # Caller data:
     for key in ('caller_sex', 'caller_education', 'caller_birth_year', 'caller_dialect_area'):
         full_key = 'from_' + key
         if self.caller.endswith("B"):
             full_key = 'to_' + key            
         setattr(self, key, transcript_metadata[full_key])
开发者ID:mrmutator,项目名称:COP_Project,代码行数:42,代码来源:swda.py


注:本文中的nltk.tree.Tree.split方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。