MCPcopy
hub / github.com/nltk/nltk / attempt_EqualityExpression

Method attempt_EqualityExpression

nltk/sem/logic.py:453–468  ·  view source on GitHub ↗

Attempt to make an equality expression. If the next token is an equality operator, then an EqualityExpression will be returned. Otherwise, the parameter will be returned.

(self, expression, context)

Source from the content-addressed store, hash-verified

451 return accum
452
453 def attempt_EqualityExpression(self, expression, context):
454 """Attempt to make an equality expression. If the next token is an
455 equality operator, then an EqualityExpression will be returned.
456 Otherwise, the parameter will be returned."""
457 if self.inRange(0):
458 tok = self.token(0)
459 if tok in Tokens.EQ_LIST + Tokens.NEQ_LIST and self.has_priority(
460 tok, context
461 ):
462 self.token() # swallow the "=" or "!="
463 expression = self.make_EqualityExpression(
464 expression, self.process_next_expression(tok)
465 )
466 if tok in Tokens.NEQ_LIST:
467 expression = self.make_NegatedExpression(expression)
468 return expression
469
470 def make_EqualityExpression(self, first, second):
471 """This method serves as a hook for other logic parsers that

Callers 1

attempt_adjunctsMethod · 0.95

Calls 6

inRangeMethod · 0.95
tokenMethod · 0.95
has_priorityMethod · 0.95

Tested by

no test coverage detected