Module ImportFrom alias ImportFrom alias ImportFrom alias Expr Str Assign NameStore ListLoad Str TryExcept body ImportFrom alias ImportFrom alias FunctionDef arguments args defaults body Pass decorator_list handlers ExceptHandler type NameLoad name NameStore body FunctionDef arguments args NameParam defaults NameLoad body Raise Call NameLoad BinOpMod Str NameLoad decorator_list FunctionDef arguments args NameParam defaults body TryExcept body For TupleStore NameStore NameStore Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Str handlers ExceptHandler type NameLoad body Raise Call NameLoad BinOpMod Str TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad NameLoad NameLoad body Expr Str Expr Call NameLoad Assign NameStore BoolOpOr NameLoad Dict Assign NameStore BoolOpOr NameLoad Dict Assign AttributeStore NameLoad attr Call NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad If BoolOpAnd NameLoad NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad keyword NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call NameLoad NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad For NameStore NameLoad body Expr Yield Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore ListLoad Assign NameStore Dict For TupleStore NameStore TupleStore NameStore NameStore Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If CompareIsNot NameLoad NameLoad body Assign SubscriptStore NameLoad Index NameLoad NameLoad Expr Call NameLoad NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad For NameStore NameLoad body Expr Yield Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign TupleStore NameStore NameStore NameStore Call NameLoad NameLoad Return Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list NameLoad decorator_list FunctionDef arguments args defaults body Expr Str ImportFrom alias Assign NameStore AttributeLoad Call NameLoad Str attr Expr Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Str Assign NameStore Call AttributeLoad Str attr Assign NameStore Call AttributeLoad Str attr Assign NameStore Call AttributeLoad Str attr For NameStore TupleLoad NameLoad NameLoad NameLoad body Expr Call NameLoad BinOpMod Str Call AttributeLoad Str attr NameLoad TryExcept body Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad NameLoad handlers ExceptHandler type NameLoad body Expr Call NameLoad Str For TupleStore NameStore NameStore Call NameLoad Call AttributeLoad NameLoad attr NameLoad body Expr Call NameLoad BinOpMod Str TupleLoad NameLoad NameLoad Expr Call NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr ListLoad TupleLoad Str NameLoad TupleLoad Str Str Expr Call NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr ListLoad TupleLoad Str Str TupleLoad Str Str Expr Call NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr ListLoad TupleLoad Str Str TupleLoad Str NameLoad decorator_list FunctionDef arguments args NameParam defaults body ImportFrom alias TryExcept body Expr Call NameLoad handlers ExceptHandler type NameLoad body Raise Call NameLoad Str decorator_list
N/A __future__ print_function nltk.parse.api ParserI nltk.tree Tree N/A 
Interface for parsing with BLLIP Parser. Requires the Python
bllipparser module. BllipParser objects can be constructed with the
``BllipParser.from_unified_model_dir`` class method or manually using the
``BllipParser`` constructor. The former is generally easier if you have
a BLLIP Parser unified model directory -- a basic model can be obtained
from NLTK's downloader. More unified parsing models can be obtained with
BLLIP Parser's ModelFetcher (run ``python -m bllipparser.ModelFetcher``
or see docs for ``bllipparser.ModelFetcher.download_and_install_model``).

Basic usage::

    # download and install a basic unified parsing model (Wall Street Journal)
    # sudo python -m nltk.downloader bllip_wsj_no_aux

    >>> from nltk.data import find
    >>> model_dir = find('models/bllip_wsj_no_aux').path
    >>> bllip = BllipParser.from_unified_model_dir(model_dir)

    # 1-best parsing
    >>> sentence1 = 'British left waffles on Falklands .'.split()
    >>> top_parse = bllip.parse_one(sentence1)
    >>> print(top_parse)
    (S1
      (S
        (NP (JJ British) (NN left))
        (VP (VBZ waffles) (PP (IN on) (NP (NNP Falklands))))
        (. .)))

    # n-best parsing
    >>> sentence2 = 'Time flies'.split()
    >>> all_parses = bllip.parse_all(sentence2)
    >>> print(len(all_parses))
    50
    >>> print(all_parses[0])
    (S1 (S (NP (NNP Time)) (VP (VBZ flies))))

    # incorporating external tagging constraints (None means unconstrained tag)
    >>> constrained1 = bllip.tagged_parse([('Time', 'VB'), ('flies', 'NNS')])
    >>> print(next(constrained1))
    (S1 (NP (VB Time) (NNS flies)))
    >>> constrained2 = bllip.tagged_parse([('Time', 'NN'), ('flies', None)])
    >>> print(next(constrained2))
    (S1 (NP (NN Time) (VBZ flies)))

References
----------

- Charniak, Eugene. "A maximum-entropy-inspired parser." Proceedings of
  the 1st North American chapter of the Association for Computational
  Linguistics conference. Association for Computational Linguistics,
  2000.

- Charniak, Eugene, and Mark Johnson. "Coarse-to-fine n-best parsing
  and MaxEnt discriminative reranking." Proceedings of the 43rd Annual
  Meeting on Association for Computational Linguistics. Association
  for Computational Linguistics, 2005.

Known issues
------------

Note that BLLIP Parser is not currently threadsafe. Since this module
uses a SWIG interface, it is potentially unsafe to create multiple
``BllipParser`` objects in the same process. BLLIP Parser currently
has issues with non-ASCII text and will raise an error if given any.

See http://pypi.python.org/pypi/bllipparser/ for more information
on BLLIP Parser's Python interface.
 N/A __all__ N/A BllipParser N/A N/A bllipparser RerankingParser bllipparser.RerankingParser get_unified_model_parameters _ensure_bllip_import_or_error N/A N/A N/A N/A N/A N/A N/A N/A N/A ImportError N/A ie N/A _ensure_bllip_import_or_error N/A N/A ie N/A ie N/A N/A N/A ImportError N/A Couldn't import bllipparser module: %s ie N/A _ensure_ascii N/A N/A words N/A N/A N/A N/A N/A N/A i word N/A enumerate words N/A N/A N/A N/A word decode ascii N/A N/A N/A UnicodeDecodeError N/A N/A N/A ValueError N/A Token %d (%r) is non-ASCII. BLLIP Parser currently doesn't support non-ASCII inputs. N/A i word N/A _scored_parse_to_nltk_tree N/A N/A scored_parse N/A N/A N/A N/A N/A Tree fromstring N/A str N/A scored_parse ptb_parse N/A BllipParser N/A ParserI N/A N/A 
    Interface for parsing with BLLIP Parser. BllipParser objects can be
    constructed with the ``BllipParser.from_unified_model_dir`` class
    method or manually using the ``BllipParser`` constructor.
     __init__ N/A N/A self parser_model reranker_features reranker_weights parser_options reranker_options N/A None None None None None N/A N/A 
        Load a BLLIP Parser model from scratch. You'll typically want to
        use the ``from_unified_model_dir()`` class method to construct
        this object.

        :param parser_model: Path to parser model directory
        :type parser_model: str

        :param reranker_features: Path the reranker model's features file
        :type reranker_features: str

        :param reranker_weights: Path the reranker model's weights file
        :type reranker_weights: str

        :param parser_options: optional dictionary of parser options, see
        ``bllipparser.RerankingParser.RerankingParser.load_parser_options()``
        for more information.
        :type parser_options: dict(str)

        :param reranker_options: optional
        dictionary of reranker options, see
        ``bllipparser.RerankingParser.RerankingParser.load_reranker_model()``
        for more information.
        :type reranker_options: dict(str)
         N/A N/A _ensure_bllip_import_or_error N/A parser_options N/A parser_options N/A N/A reranker_options N/A reranker_options N/A N/A N/A self rrp N/A RerankingParser N/A N/A N/A N/A self rrp load_parser_model parser_model parser_options N/A N/A reranker_features reranker_weights N/A N/A N/A N/A N/A self rrp load_reranker_model features_filename reranker_features weights_filename reranker_weights reranker_options N/A parse N/A N/A self sentence N/A N/A N/A 
        Use BLLIP Parser to parse a sentence. Takes a sentence as a list
        of words; it will be automatically tagged with this BLLIP Parser
        instance's tagger.

        :return: An iterator that generates parse trees for the sentence
        from most likely to least likely.

        :param sentence: The sentence to be parsed
        :type sentence: list(str)
        :rtype: iter(Tree)
         N/A N/A _ensure_ascii sentence N/A nbest_list N/A N/A N/A self rrp parse sentence N/A scored_parse nbest_list N/A N/A N/A N/A _scored_parse_to_nltk_tree scored_parse N/A tagged_parse N/A N/A self word_and_tag_pairs N/A N/A N/A 
        Use BLLIP to parse a sentence. Takes a sentence as a list of
        (word, tag) tuples; the sentence must have already been tokenized
        and tagged. BLLIP will attempt to use the tags provided but may
        use others if it can't come up with a complete parse subject
        to those constraints. You may also specify a tag as ``None``
        to leave a token's tag unconstrained.

        :return: An iterator that generates parse trees for the sentence
        from most likely to least likely.

        :param sentence: Input sentence to parse as (word, tag) pairs
        :type sentence: list(tuple(str, str))
        :rtype: iter(Tree)
         N/A words N/A N/A tag_map N/A N/A N/A i N/A word tag N/A enumerate word_and_tag_pairs N/A N/A N/A N/A words append word N/A N/A tag None N/A N/A N/A tag_map N/A i tag N/A N/A _ensure_ascii words N/A nbest_list N/A N/A N/A self rrp parse_tagged words tag_map N/A scored_parse nbest_list N/A N/A N/A N/A _scored_parse_to_nltk_tree scored_parse N/A from_unified_model_dir N/A N/A this_class model_dir parser_options reranker_options N/A None None N/A N/A 
        Create a ``BllipParser`` object from a unified parsing model
        directory. Unified parsing model directories are a standardized
        way of storing BLLIP parser and reranker models together on disk.
        See ``bllipparser.RerankingParser.get_unified_model_parameters()``
        for more information about unified model directories.

        :return: A ``BllipParser`` object using the parser and reranker
        models in the model directory.

        :param model_dir: Path to the unified model directory.
        :type model_dir: str
        :param parser_options: optional dictionary of parser options, see
        ``bllipparser.RerankingParser.RerankingParser.load_parser_options()``
        for more information.
        :type parser_options: dict(str)
        :param reranker_options: optional dictionary of reranker options, see
        ``bllipparser.RerankingParser.RerankingParser.load_reranker_model()``
        for more information.
        :type reranker_options: dict(str)
        :rtype: BllipParser
         N/A N/A parser_model_dir reranker_features_filename reranker_weights_filename N/A get_unified_model_parameters model_dir N/A N/A this_class parser_model_dir reranker_features_filename reranker_weights_filename parser_options reranker_options N/A classmethod N/A demo N/A N/A N/A N/A N/A This assumes the Python module bllipparser is installed. nltk.data find N/A model_dir N/A N/A find models/bllip_wsj_no_aux path N/A N/A print Loading BLLIP Parsing models... N/A bllip N/A N/A BllipParser from_unified_model_dir model_dir N/A N/A print Done. N/A sentence1 N/A N/A British left waffles on Falklands . split N/A sentence2 N/A N/A I saw the man with the telescope . split N/A fail1 N/A N/A # ! ? : - split N/A sentence N/A sentence1 sentence2 fail1 N/A N/A N/A print N/A Sentence: %r N/A N/A join sentence N/A N/A N/A tree N/A next N/A N/A bllip parse sentence N/A N/A print tree N/A N/A N/A StopIteration N/A N/A N/A print (parse failed) N/A N/A i parse N/A enumerate N/A N/A bllip parse sentence1 N/A N/A N/A print N/A parse %d:
%s N/A i parse N/A N/A print forcing 'tree' to be 'NN': N/A next N/A N/A bllip tagged_parse N/A N/A A None N/A tree NN N/A N/A print forcing 'A' to be 'DT' and 'tree' to be 'NNP': N/A next N/A N/A bllip tagged_parse N/A N/A A DT N/A tree NNP N/A N/A print forcing 'A' to be 'NNP': N/A next N/A N/A bllip tagged_parse N/A N/A A NNP N/A tree None N/A setup_module N/A N/A module N/A N/A nose SkipTest N/A N/A N/A N/A _ensure_bllip_import_or_error N/A N/A N/A ImportError N/A N/A N/A SkipTest doctests from nltk.parse.bllip are skipped because the bllipparser module is not installed N/A