comparison service/reasoning/reasoning.py @ 1040:2fa7daf06f34

rdflib can parse trig now Ignore-this: ad1feb1d88249f509d2906b6cdbe62c6 darcs-hash:c141fa6a86e7d395c4c80facc9ed7fcadcf40b29
author drewp <drewp@bigasterisk.com>
date Mon, 01 Feb 2016 02:15:23 -0800
parents 7e99f05c21cd
children 0c306e76d8c5
comparison
equal deleted inserted replaced
1039:77e7e8d76a81 1040:2fa7daf06f34
22 from rdflib import Graph, ConjunctiveGraph 22 from rdflib import Graph, ConjunctiveGraph
23 from rdflib import Namespace, URIRef, Literal, RDF 23 from rdflib import Namespace, URIRef, Literal, RDF
24 from rdflib.parser import StringInputSource 24 from rdflib.parser import StringInputSource
25 from cyclone.httpclient import fetch 25 from cyclone.httpclient import fetch
26 import cyclone.web, cyclone.websocket 26 import cyclone.web, cyclone.websocket
27 from inference import addTrig, infer 27 from inference import infer
28 from rdflibtrig import addTrig
28 from graphop import graphEqual 29 from graphop import graphEqual
29 from docopt import docopt 30 from docopt import docopt
30 31
31 from FuXi.Rete.RuleStore import N3RuleStore 32 from FuXi.Rete.RuleStore import N3RuleStore
32 33
167 self.inferred = Graph() # gets replaced in each graphChanged call 168 self.inferred = Graph() # gets replaced in each graphChanged call
168 169
169 self.inputGraph = InputGraph([], self.graphChanged) 170 self.inputGraph = InputGraph([], self.graphChanged)
170 self.inputGraph.updateFileData() 171 self.inputGraph.updateFileData()
171 172
172
173 def readRules(self): 173 def readRules(self):
174 self.rulesN3 = open('rules.n3').read() # for web display 174 self.rulesN3 = open('rules.n3').read() # for web display
175 self.ruleStore = N3RuleStore() 175 self.ruleStore = N3RuleStore()
176 self.ruleGraph = Graph(self.ruleStore) 176 self.ruleGraph = Graph(self.ruleStore)
177 self.ruleGraph.parse('rules.n3', format='n3') # for inference 177 self.ruleGraph.parse('rules.n3', format='n3') # for inference
557 -v Verbose 557 -v Verbose
558 """) 558 """)
559 559
560 r = Reasoning() 560 r = Reasoning()
561 if arg['-v']: 561 if arg['-v']:
562 from colorlog import ColoredFormatter
563 log.handlers[0].setFormatter(ColoredFormatter("%(log_color)s%(levelname)-8s%(reset)s %(white)s%(message)s",
564 datefmt=None,
565 reset=True,
566 log_colors={
567 'DEBUG': 'cyan',
568 'INFO': 'green',
569 'WARNING': 'yellow',
570 'ERROR': 'red',
571 'CRITICAL': 'red,bg_white',
572 },
573 secondary_log_colors={},
574 style='%'
575 ))
576
562 import twisted.python.log 577 import twisted.python.log
563 twisted.python.log.startLogging(sys.stdout) 578 twisted.python.log.startLogging(sys.stdout)
564 log.setLevel(logging.DEBUG) 579 log.setLevel(logging.DEBUG)
565 outlog.setLevel(logging.DEBUG) 580 outlog.setLevel(logging.DEBUG)
566 581
567 task.LoopingCall(r.poll).start(1.0) 582 task.LoopingCall(r.poll).start(1.0)
568 reactor.listenTCP(9071, Application(r)) 583 reactor.listenTCP(9071, Application(r), interface='::')
569 reactor.run() 584 reactor.run()