Код: Выделить всё
ccg = '''
# CCG grammar
# complete the lexical entries with their categories and semantics
:- S, NP, N
logicians => NP { \\x. LOGICIANS(x) }
logicians => N { \\x. LOGICIANS(x) }
linguists => NP { \\x. LINGUISTS(x) }
linguists => N { \\x. LINGUISTS(x) }
engineers => NP { \\x. ENGINEERS(x) }
engineers => N { \\x. ENGINEERS(x) }
non => NP/N { \\N x. ~N(x) }
are => (S\\NP)/NP {\\x y.are(x,y)}
all => NP/N { \\P Q. all x. (P(x) -> Q(x)) }
no => NP/N { \\P Q. all x. (P(x) -> ~Q(x)) }
some => NP/N { \\N V. exists x. (N(x) & V(x)) }
'''
Код: Выделить всё
are => (S\\NP)/NP {\\X x.X(\y.are(x,y))}
Код: Выделить всё
S {are(\x.LINGUISTS(x),\Q.all x.(LOGICIANS(x) -> Q(x)))}
Код: Выделить всё
are => (S\\NP)/NP { \\X Y. all y. (X(y) Y(y)) }
Код: Выделить всё
LogicalExpressionException Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/nltk/sem/logic.py in parse(self, data, signature)
153 try:
--> 154 result = self.process_next_expression(None)
155 if self.inRange(0):
24 frames
LogicalExpressionException: 'y' is an illegal predicate name. Individual variables may not be used as predicates.
The above exception was the direct cause of the following exception:
LogicalExpressionException Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/nltk/sem/logic.py in parse(self, data, signature)
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:
LogicalExpressionException: 'y' is an illegal predicate name. Individual variables may not be used as predicates.
all y.(LINGUISTS(y) all x.(LOGICIANS(x) -> y(x)))
Подробнее здесь: https://stackoverflow.com/questions/792 ... culus-nltk
Мобильная версия