當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。