-
Notifications
You must be signed in to change notification settings - Fork 0
/
thinkpudding.py
69 lines (58 loc) · 2.58 KB
/
thinkpudding.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import json
import sys
import warnings
import time
import logging
import json
#from asyncore import read
import pandas as pd
from rdflib import Graph, Literal, Namespace, URIRef,BNode
from rdflib.collection import Collection
from rdflib.namespace import FOAF, RDF, RDFS, SKOS, XSD
from rdflib.serializer import Serializer
from rdfpandas.graph import to_dataframe
from SPARQLWrapper import XML, SPARQLWrapper
import collections
from load import read,process_causalpathways,process_spek,matching
from insert import insert
class Thinkpudding:
start_time1 = time.time()
spek_out_dicts = {}
caus_out_dict={}
final_dict={}
def __init__(self, spek_cs: str = "{}", causal_pathways: str = "{}"):
start_time = time.time()
#self.spek_cs1 = json.dumps(spek_cs)
self.spek_cs=read(spek_cs)
logging.critical(" reading spek graph--- %s seconds ---" % (time.time() - start_time))
start_time = time.time()
#self.causal_pathways1 = json.dumps(causal_pathways)
self.causal_pathways=read(causal_pathways)
logging.critical(" reading causal pathways graph--- %s seconds ---" % (time.time() - start_time))
def process_causalpathways(self):
start_time = time.time()
self.caus_out_dict=process_causalpathways(self.causal_pathways)
# for k,v in self.caus_out_dict.items():
# print(k,v)
logging.critical(" processing causal pathways--- %s seconds ---" % (time.time() - start_time))
def process_spek(self):
start_time = time.time()
self.spek_out_dicts,self.comparator_dicts=process_spek(self.spek_cs)
logging.critical(" processing spek_cs--- %s seconds ---" % (time.time() - start_time))
def matching(self):
start_time = time.time()
# matching(self.caus_out_dict,self.spek_out_dicts,self.comparator_dicts)
self.merged_list=matching(self.caus_out_dict,self.spek_out_dicts,self.comparator_dicts)
# for x in range(len(self.merged_list)):
# print(self.merged_list[x])
logging.critical(" processing matching--- %s seconds ---" % (time.time() - start_time))
def insert(self):
start_time = time.time()
self.spek_tp=insert(self.merged_list,self.spek_cs)
logging.critical(" inserting acceptable by--- %s seconds ---" % (time.time() - start_time))
return self.spek_tp
# print(spek_tp.serialize(format='json-ld', indent=4))
# logging.critical("complete thinkpudding--- %s seconds ---" % (time.time() - start_time1))
#print(caus_out_dict)
#print(spek_out_dicts)
#print(final_dict)