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


Python chunk.RegexpParser方法代码示例

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


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

示例1: _chunk_parse

# 需要导入模块: from nltk import chunk [as 别名]
# 或者: from nltk.chunk import RegexpParser [as 别名]
def _chunk_parse(self, grammar=None, root_label='record', trace=0, **kwargs):
        """
        Returns an element tree structure corresponding to a toolbox data file
        parsed according to the chunk grammar.

        :type grammar: str
        :param grammar: Contains the chunking rules used to parse the
            database.  See ``chunk.RegExp`` for documentation.
        :type root_label: str
        :param root_label: The node value that should be used for the
            top node of the chunk structure.
        :type trace: int
        :param trace: The level of tracing that should be used when
            parsing a text.  ``0`` will generate no tracing output;
            ``1`` will generate normal tracing output; and ``2`` or
            higher will generate verbose tracing output.
        :type kwargs: dict
        :param kwargs: Keyword arguments passed to ``toolbox.StandardFormat.fields()``
        :rtype: ElementTree._ElementInterface
        """
        from nltk import chunk
        from nltk.tree import Tree

        cp = chunk.RegexpParser(grammar, root_label=root_label, trace=trace)
        db = self.parse(**kwargs)
        tb_etree = Element('toolbox_data')
        header = db.find('header')
        tb_etree.append(header)
        for record in db.findall('record'):
            parsed = cp.parse([(elem.text, elem.tag) for elem in record])
            tb_etree.append(self._tree2etree(parsed))
        return tb_etree 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:34,代码来源:toolbox.py

示例2: _chunk_parse

# 需要导入模块: from nltk import chunk [as 别名]
# 或者: from nltk.chunk import RegexpParser [as 别名]
def _chunk_parse(self, grammar=None, top_node='record', trace=0, **kwargs):
        """
        Returns an element tree structure corresponding to a toolbox data file
        parsed according to the chunk grammar.

        :type grammar: str
        :param grammar: Contains the chunking rules used to parse the
            database.  See ``chunk.RegExp`` for documentation.
        :type top_node: str
        :param top_node: The node value that should be used for the
            top node of the chunk structure.
        :type trace: int
        :param trace: The level of tracing that should be used when
            parsing a text.  ``0`` will generate no tracing output;
            ``1`` will generate normal tracing output; and ``2`` or
            higher will generate verbose tracing output.
        :type kwargs: dict
        :param kwargs: Keyword arguments passed to ``toolbox.StandardFormat.fields()``
        :rtype: ElementTree._ElementInterface
        """
        from nltk import chunk
        from nltk.tree import Tree

        cp = chunk.RegexpParser(grammar, top_node=top_node, trace=trace)
        db = self.parse(**kwargs)
        tb_etree = Element('toolbox_data')
        header = db.find('header')
        tb_etree.append(header)
        for record in db.findall('record'):
            parsed = cp.parse([(elem.text, elem.tag) for elem in record])
            tb_etree.append(self._tree2etree(parsed))
        return tb_etree 
开发者ID:blackye,项目名称:luscan-devel,代码行数:34,代码来源:toolbox.py

示例3: initialize

# 需要导入模块: from nltk import chunk [as 别名]
# 或者: from nltk.chunk import RegexpParser [as 别名]
def initialize(self, resources: Resources, configs: Config):
        super().initialize(resources, configs)
        self.chunker = RegexpParser(configs.pattern) 
开发者ID:asyml,项目名称:forte,代码行数:5,代码来源:nltk_processors.py

示例4: __str__

# 需要导入模块: from nltk import chunk [as 别名]
# 或者: from nltk.chunk import RegexpParser [as 别名]
def __str__(self):
        """
        :return: a verbose string representation of this
            ``RegexpParser``.
        :rtype: str
        """
        s = "chunk.RegexpParser with %d stages:\n" % len(self._stages)
        margin = 0
        for parser in self._stages:
            s += "%s\n" % parser
        return s[:-1]


##//////////////////////////////////////////////////////
##  Demonstration code
##////////////////////////////////////////////////////// 
开发者ID:V1EngineeringInc,项目名称:V1EngineeringInc-Docs,代码行数:18,代码来源:regexp.py

示例5: __repr__

# 需要导入模块: from nltk import chunk [as 别名]
# 或者: from nltk.chunk import RegexpParser [as 别名]
def __repr__(self):
        """
        :return: a concise string representation of this ``chunk.RegexpParser``.
        :rtype: str
        """
        return "<chunk.RegexpParser with %d stages>" % len(self._stages) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:8,代码来源:regexp.py

示例6: __str__

# 需要导入模块: from nltk import chunk [as 别名]
# 或者: from nltk.chunk import RegexpParser [as 别名]
def __str__(self):
        """
        :return: a verbose string representation of this
            ``RegexpParser``.
        :rtype: str
        """
        s = "chunk.RegexpParser with %d stages:\n" % len(self._stages)
        margin = 0
        for parser in self._stages:
            s += "%s\n" % parser
        return s[:-1]

##//////////////////////////////////////////////////////
##  Demonstration code
##////////////////////////////////////////////////////// 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:17,代码来源:regexp.py

示例7: __str__

# 需要导入模块: from nltk import chunk [as 别名]
# 或者: from nltk.chunk import RegexpParser [as 别名]
def __str__(self):
        """
        :return: a verbose string representation of this
            ``RegexpParser``.
        :rtype: str
        """
        s = "chunk.RegexpParser with %d stages:\n" % len(self._stages)
        margin = 0
        for parser in self._stages:
            s += parser.__str__() + "\n"
        return s[:-1]

##//////////////////////////////////////////////////////
##  Demonstration code
##////////////////////////////////////////////////////// 
开发者ID:blackye,项目名称:luscan-devel,代码行数:17,代码来源:regexp.py


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