本文整理汇总了Python中nltk.sem.logic.LogicParser.parse方法的典型用法代码示例。如果您正苦于以下问题:Python LogicParser.parse方法的具体用法?Python LogicParser.parse怎么用?Python LogicParser.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.sem.logic.LogicParser
的用法示例。
在下文中一共展示了LogicParser.parse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tableau_test
# 需要导入模块: from nltk.sem.logic import LogicParser [as 别名]
# 或者: from nltk.sem.logic.LogicParser import parse [as 别名]
def tableau_test(c, ps=None, verbose=False):
lp = LogicParser()
pc = lp.parse(c)
pps = ([lp.parse(p) for p in ps] if ps else [])
if not ps:
ps = []
print('%s |- %s: %s' % (', '.join(ps), pc, TableauProver().prove(pc, pps, verbose=verbose)))
示例2: demo
# 需要导入模块: from nltk.sem.logic import LogicParser [as 别名]
# 或者: from nltk.sem.logic.LogicParser import parse [as 别名]
def demo():
from nltk_contrib.drt import DRT
DRT.testTp_equals()
print '\n'
lp = LogicParser()
a = lp.parse(r'some x.((man x) and (walks x))')
b = lp.parse(r'some x.((walks x) and (man x))')
bicond = ApplicationExpression(ApplicationExpression(Operator('iff'), a), b)
print "Trying to prove:\n '%s <-> %s'" % (a.infixify(), b.infixify())
print 'tableau: %s' % get_prover(bicond, prover_name='tableau').prove()
print 'Prover9: %s' % get_prover(bicond, prover_name='Prover9').prove()
print '\n'
demo_drt_glue_remove_duplicates()
lp = LogicParser()
a = lp.parse(r'all x.((man x) implies (mortal x))')
b = lp.parse(r'(man socrates)')
c1 = lp.parse(r'(mortal socrates)')
c2 = lp.parse(r'(not (mortal socrates))')
print get_prover(c1, [a,b], 'prover9').prove()
print get_prover(c2, [a,b], 'prover9').prove()
print get_model_builder(c1, [a,b], 'mace').build_model()
print get_model_builder(c2, [a,b], 'mace').build_model()
示例3: combination_prover_demo
# 需要导入模块: from nltk.sem.logic import LogicParser [as 别名]
# 或者: from nltk.sem.logic.LogicParser import parse [as 别名]
def combination_prover_demo():
lp = LogicParser()
p1 = lp.parse(r'see(Socrates, John)')
p2 = lp.parse(r'see(John, Mary)')
c = lp.parse(r'-see(Socrates, Mary)')
prover = Prover9Command(c, [p1,p2])
print(prover.prove())
command = ClosedDomainProver(
UniqueNamesProver(
ClosedWorldProver(prover)))
for a in command.assumptions(): print(a)
print(command.prove())