Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this user
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
gadelrab
/
ExFaKT
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security
Insights
Files
c2288d2
Api
Client
Demo
Extras
FactSpotting
QueryRewriting
libs
src/main
java
checker
config
datastructure
experiments
extendedsldnf
datastructure
facts
FactsLoaderFactory.java
IFactsLoader.java
IRISFactsLoader.java
RDFFactsLoader.java
rules
viewing
CostAccumulator.java
EvaluatorFactory.java
ExtendedSLDNFEvaluationStrategy.java
ExtendedSLDNFEvaluationStrategyFactory.java
FactsUtils.java
IExplanationGenerator.java
ItrSLDEvaluator.java
OptimizedLiteralSelector.java
RecSLDEvaluator.java
text
utils
DocumentCollector.java
JSONConverter.java
MainCLI.java
resources
pom.xml
Utils
WebService
WebService2
data
scripts
src
.gitignore
.gitmodules
README.md
install_external_jars.sh
pom.xml
rules_splitq_heursitic.out.json
Breadcrumbs
ExFaKT
/
QueryRewriting
/
src
/
main
/
java
/
extendedsldnf
/
facts
/
RDFFactsLoader.java
Blame
Blame
Latest commit
History
History
executable file
·
144 lines (104 loc) · 4.68 KB
Breadcrumbs
ExFaKT
/
QueryRewriting
/
src
/
main
/
java
/
extendedsldnf
/
facts
/
RDFFactsLoader.java
Top
File metadata and controls
Code
Blame
executable file
·
144 lines (104 loc) · 4.68 KB
Raw
package extendedsldnf.facts; import config.Configuration; import de.mpii.dataprocessing.util.FactUtils; import extendedsldnf.datastructure.InputQuery; import org.deri.iris.api.basics.IAtom; import org.deri.iris.api.basics.ILiteral; import org.deri.iris.api.basics.IPredicate; import org.deri.iris.api.basics.ITuple; import org.deri.iris.api.factory.IBasicFactory; import org.deri.iris.api.factory.ITermFactory; import org.deri.iris.api.terms.ITerm; import org.deri.iris.basics.BasicFactory; import org.deri.iris.storage.IRelation; import org.deri.iris.storage.IRelationFactory; import org.deri.iris.terms.TermFactory; import java.io.BufferedReader; import java.io.IOException; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; /** * Created by gadelrab on 4/12/17. */ public class RDFFactsLoader extends IFactsLoader{ static RDFFactsLoader instance; public RDFFactsLoader(IRelationFactory relationFactory) { super(relationFactory); } @Override public Map<IPredicate, IRelation> parseFacts(BufferedReader fileReader) { //TODO parse the file check if it is implemented in RDF-IRIS-reasoner Map<IPredicate, IRelation> factsMap=new HashMap<>(); try { IBasicFactory basicFactory = BasicFactory.getInstance(); ITermFactory termFactory= TermFactory.getInstance(); IRelationFactory relationFactory=getRelationFactory(); IRelation relation=null; for(String line=fileReader.readLine();line!=null;line=fileReader.readLine()){ if(line==null || line.isEmpty()) continue; String[] parts=line.split("\t"); // Create the predicate String cleanPredicateName= FactUtils.getCleanPredicateName(parts[1]); IPredicate predicate= basicFactory.createPredicate(cleanPredicateName,2); // arguments ITerm term1= termFactory.createString(parts[0]); ITerm term2= termFactory.createString(parts[2]); ITuple tuple= basicFactory.createTuple(term1,term2); // Add fact to map if(!factsMap.containsKey(predicate)){ relation=relationFactory.createRelation(); factsMap.put(predicate,relation); }else{ relation= factsMap.get(predicate); } relation.add(tuple); } } catch (IOException e) { e.printStackTrace(); } return factsMap; } @Override public LinkedHashMap<InputQuery, Integer> parseQueries(BufferedReader fileReader) { //TODO parse the file check if it is implemented in RDF-IRIS-reasoner LinkedHashMap<InputQuery, Integer> queries=new LinkedHashMap<>(); try { IBasicFactory basicFactory = BasicFactory.getInstance(); ITermFactory termFactory= TermFactory.getInstance(); IRelationFactory relationFactory=getRelationFactory(); IRelation relation=null; int i=0; for(String line=fileReader.readLine();line!=null;line=fileReader.readLine()){ if(line==null || line.isEmpty()) continue; i++; String[] parts=line.split("\t"); // Create the predicate String cleanPredicateName= FactUtils.getCleanPredicateName(parts[1]); IPredicate predicate= basicFactory.createPredicate(cleanPredicateName,2); // arguments ITerm term1= parts[0].startsWith("?")? termFactory.createVariable(parts[0].substring(1)):termFactory.createString(parts[0]); ITerm term2= parts[2].startsWith("?")? termFactory.createVariable(parts[2].substring(1)):termFactory.createString(parts[2]); ITuple tuple= basicFactory.createTuple(term1,term2); IAtom atom = basicFactory.createAtom(predicate, tuple); ILiteral literal = basicFactory.createLiteral(true, atom); Integer label= (parts.length>3)? Integer.valueOf(parts[3]) :1; queries.put(new InputQuery(basicFactory.createQuery(literal),i,label),label); } } catch (IOException e) { e.printStackTrace(); } return queries; } public static RDFFactsLoader getInstance(Configuration configuration) { return getInstance(configuration.relationFactory); } public static RDFFactsLoader getInstance(IRelationFactory relationFactory) { if(instance==null){ instance=new RDFFactsLoader(relationFactory); } return instance; } }
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
You can’t perform that action at this time.