1
2
3
4
5
6
7
8
9
10 """
11 Classes and interfaces for producing tree structures that represent
12 the internal organization of a text. This task is known as X{parsing}
13 the text, and the resulting tree structures are called the text's
14 X{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
21 Sometimes, a single piece of text can be represented by more than one
22 tree structure. Texts represented by more than one tree structure are
23 called X{ambiguous} texts. Note that there are actually two ways in
24 which a text can be ambiguous:
25
26 - The text has multiple correct parses.
27 - There is not enough information to decide which of several
28 candidate parses is correct.
29
30 However, the parser module does I{not} distinguish these two types of
31 ambiguity.
32
33 The parser module defines C{ParserI}, a standard interface for parsing
34 texts; and two simple implementations of that interface,
35 C{ShiftReduceParser} and C{RecursiveDescentParser}. It also contains
36 three sub-modules for specialized kinds of parsing:
37
38 - C{nltk.parser.chart} defines chart parsing, which uses dynamic
39 programming to efficiently parse texts.
40 - C{nltk.parser.probabilistic} defines probabilistic parsing, which
41 associates a probability with each parse.
42 """
43
44 from api import *
45 from chart import *
46 from featurechart import *
47 from pchart import *
48 from rd import *
49 from sr import *
50 from util import *
51 from viterbi import *
52
53 __all__ = [
54
55 'ParserI',
56
57
58 'RecursiveDescentParser', 'SteppingRecursiveDescentParser',
59 'ShiftReduceParser', 'SteppingShiftReduceParser',
60 'EarleyChartParser', 'ChartParser', 'SteppingChartParser',
61 'BottomUpChartParser', 'InsideChartParser', 'RandomChartParser',
62 'UnsortedChartParser', 'LongestChartParser', 'ViterbiParser',
63 'FeatureEarleyChartParser',
64
65 ]
66
67
68
69
70 from nltk.internals import Deprecated
71 -class ParseI(ParserI, Deprecated):
72 """Use nltk.ParserI instead."""
74 """Use nltk.ParserI instead."""
76 """Use nltk.RecursiveDescentParser instead."""
78 """Use nltk.SteppingRecursiveDescentParser instead."""
80 """Use nltk.ShiftReduceParser instead."""
82 """Use nltk.SteppingShiftReduceParser instead."""
84 """Use nltk.EarleyChartParser instead."""
86 """Use nltk.FeatureEarleyChartParser instead."""
88 """Use nltk.ChartParser instead."""
90 """Use nltk.SteppingChartParser instead."""
92 """Use nltk.BottomUpChartParser instead."""
94 """Use nltk.InsideChartParser instead."""
96 """Use nltk.RandomChartParser instead."""
98 """Use nltk.UnsortedChartParser instead."""
100 """Use nltk.LongestChartParser instead."""
102 """Use nltk.ViterbiParser instead."""
104 """Use nltk.data.load() instead."""
105
106 - def __init__(self, filename=None, verbose=False):
107 raise ValueError("GrammarFile is no longer supported -- "
108 "use nltk.data.load() instead.")
109