__init__.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # Natural Language Toolkit: Parsers
  2. #
  3. # Copyright (C) 2001-2020 NLTK Project
  4. # Author: Steven Bird <stevenbird1@gmail.com>
  5. # Edward Loper <edloper@gmail.com>
  6. # URL: <http://nltk.org/>
  7. # For license information, see LICENSE.TXT
  8. #
  9. """
  10. NLTK Parsers
  11. Classes and interfaces for producing tree structures that represent
  12. the internal organization of a text. This task is known as "parsing"
  13. the text, and the resulting tree structures are called the text's
  14. "parses". Typically, the text is a single sentence, and the tree
  15. structure represents the syntactic structure of the sentence.
  16. However, parsers can also be used in other domains. For example,
  17. parsers can be used to derive the morphological structure of the
  18. morphemes that make up a word, or to derive the discourse structure
  19. for a set of utterances.
  20. Sometimes, a single piece of text can be represented by more than one
  21. tree structure. Texts represented by more than one tree structure are
  22. called "ambiguous" texts. Note that there are actually two ways in
  23. which a text can be ambiguous:
  24. - The text has multiple correct parses.
  25. - There is not enough information to decide which of several
  26. candidate parses is correct.
  27. However, the parser module does *not* distinguish these two types of
  28. ambiguity.
  29. The parser module defines ``ParserI``, a standard interface for parsing
  30. texts; and two simple implementations of that interface,
  31. ``ShiftReduceParser`` and ``RecursiveDescentParser``. It also contains
  32. three sub-modules for specialized kinds of parsing:
  33. - ``nltk.parser.chart`` defines chart parsing, which uses dynamic
  34. programming to efficiently parse texts.
  35. - ``nltk.parser.probabilistic`` defines probabilistic parsing, which
  36. associates a probability with each parse.
  37. """
  38. from nltk.parse.api import ParserI
  39. from nltk.parse.chart import (
  40. ChartParser,
  41. SteppingChartParser,
  42. TopDownChartParser,
  43. BottomUpChartParser,
  44. BottomUpLeftCornerChartParser,
  45. LeftCornerChartParser,
  46. )
  47. from nltk.parse.featurechart import (
  48. FeatureChartParser,
  49. FeatureTopDownChartParser,
  50. FeatureBottomUpChartParser,
  51. FeatureBottomUpLeftCornerChartParser,
  52. )
  53. from nltk.parse.earleychart import (
  54. IncrementalChartParser,
  55. EarleyChartParser,
  56. IncrementalTopDownChartParser,
  57. IncrementalBottomUpChartParser,
  58. IncrementalBottomUpLeftCornerChartParser,
  59. IncrementalLeftCornerChartParser,
  60. FeatureIncrementalChartParser,
  61. FeatureEarleyChartParser,
  62. FeatureIncrementalTopDownChartParser,
  63. FeatureIncrementalBottomUpChartParser,
  64. FeatureIncrementalBottomUpLeftCornerChartParser,
  65. )
  66. from nltk.parse.pchart import (
  67. BottomUpProbabilisticChartParser,
  68. InsideChartParser,
  69. RandomChartParser,
  70. UnsortedChartParser,
  71. LongestChartParser,
  72. )
  73. from nltk.parse.recursivedescent import (
  74. RecursiveDescentParser,
  75. SteppingRecursiveDescentParser,
  76. )
  77. from nltk.parse.shiftreduce import ShiftReduceParser, SteppingShiftReduceParser
  78. from nltk.parse.util import load_parser, TestGrammar, extract_test_sentences
  79. from nltk.parse.viterbi import ViterbiParser
  80. from nltk.parse.dependencygraph import DependencyGraph
  81. from nltk.parse.projectivedependencyparser import (
  82. ProjectiveDependencyParser,
  83. ProbabilisticProjectiveDependencyParser,
  84. )
  85. from nltk.parse.nonprojectivedependencyparser import (
  86. NonprojectiveDependencyParser,
  87. NaiveBayesDependencyScorer,
  88. ProbabilisticNonprojectiveParser,
  89. )
  90. from nltk.parse.malt import MaltParser
  91. from nltk.parse.evaluate import DependencyEvaluator
  92. from nltk.parse.transitionparser import TransitionParser
  93. from nltk.parse.bllip import BllipParser
  94. from nltk.parse.corenlp import CoreNLPParser, CoreNLPDependencyParser