MCPcopy
hub / github.com/nltk/nltk / parse

Method parse

nltk/sem/logic.py:139–164  ·  view source on GitHub ↗

Parse the expression. :param data: str for the input to be parsed :param signature: ``dict `` that maps variable names to type strings :returns: a parsed Expression

(self, data, signature=None)

Source from the content-addressed store, hash-verified

137 self.right_associated_operations = [APP]
138
139 def parse(self, data, signature=None):
140 """
141 Parse the expression.
142
143 :param data: str for the input to be parsed
144 :param signature: ``dict<str, str>`` that maps variable names to type
145 strings
146 :returns: a parsed Expression
147 """
148 data = data.rstrip()
149
150 self._currentIndex = 0
151 self._buffer, mapping = self.process(data)
152
153 try:
154 result = self.process_next_expression(None)
155 if self.inRange(0):
156 raise UnexpectedTokenException(self._currentIndex + 1, self.token(0))
157 except LogicalExpressionException as e:
158 msg = "{}\n{}\n{}^".format(e, data, " " * mapping[e.index - 1])
159 raise LogicalExpressionException(None, msg) from e
160
161 if self.type_check:
162 result.typecheck(signature)
163
164 return result
165
166 def process(self, data):
167 """Split the data into tokens"""

Callers 10

read_logicFunction · 0.95
parse_with_bindopsFunction · 0.45
fromstringMethod · 0.45
__init__Method · 0.45
dep_parseMethod · 0.45
__init__Method · 0.45
fromstringMethod · 0.45
parse_sentsFunction · 0.45
fromstringMethod · 0.45
hole_readingsFunction · 0.45

Calls 8

processMethod · 0.95
inRangeMethod · 0.95
tokenMethod · 0.95
formatMethod · 0.45
typecheckMethod · 0.45

Tested by

no test coverage detected