From e38d8f1bd88f673d733a6d032191c86fbd72a733 Mon Sep 17 00:00:00 2001 From: Reham-Osama Date: Tue, 2 Apr 2024 22:29:20 -0400 Subject: [PATCH] Draft for supporting DBLP KG --- dependency-reduced-pom.xml | 120 ++--- pom.xml | 4 +- src/main/java/database/Database.java | 4 +- src/main/java/knowledgeGraphs/DBLP.java | 429 ++++++++++++++++++ src/main/java/settings/Dblp_Settings.java | 45 ++ src/main/java/settings/Settings.java | 3 +- .../components/RandomSeedGenerator.java | 3 + .../system/components/ShapesGenerator.java | 2 +- .../java/system/components/SmartBench.java | 15 +- src/main/resources/conf.properties | 2 +- 10 files changed, 552 insertions(+), 75 deletions(-) create mode 100644 src/main/java/knowledgeGraphs/DBLP.java create mode 100644 src/main/java/settings/Dblp_Settings.java diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 1dbd2cf..38dda6c 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -1,60 +1,60 @@ - - - 4.0.0 - ca.carleton - SmartBench - SmartBench - 1.0-SNAPSHOT - - - - maven-shade-plugin - 2.1 - - - package - - shade - - - javadoc - - - - offLine.kg_explorer.explorer.Test - - - - - - - - - - - org.apache.jena - apache-jena-libs - 3.17.0 - pom - compile - - - junit - junit - 4.12 - test - - - hamcrest-core - org.hamcrest - - - - - - 1.8 - UTF-8 - 1.8 - - - + + + 4.0.0 + ca.carleton + SmartBench + SmartBench + 1.0-SNAPSHOT + + + + maven-shade-plugin + 2.1 + + + package + + shade + + + javadoc + + + + system.components.SmartBench + + + + + + + + + + + org.apache.jena + apache-jena-libs + 3.17.0 + pom + compile + + + junit + junit + 4.12 + test + + + hamcrest-core + org.hamcrest + + + + + + 1.8 + 1.8 + UTF-8 + + + diff --git a/pom.xml b/pom.xml index b7cead1..d1bd985 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ - offLine.kg_explorer.explorer.Test + system.components.SmartBench @@ -108,4 +108,4 @@ 1.8 SmartBench - \ No newline at end of file + diff --git a/src/main/java/database/Database.java b/src/main/java/database/Database.java index 8db4de4..ed87f27 100644 --- a/src/main/java/database/Database.java +++ b/src/main/java/database/Database.java @@ -122,9 +122,9 @@ public static ArrayList getAvailablePredicates(boolean order) { predicate.setPredicateURI(result.getString("PredicateURI")); predicate.setPredicateContext(new PredicateContext(result.getString("Context_Subject"), result.getString("Context_Object"), 0)); predicate.setWeight(result.getLong("ContextWeight")); - if (!predicate.getPredicateURI().contains("#")) { +// if (!predicate.getPredicateURI().contains("#")) { predicates.add(predicate); - } +// } } // con.close(); } catch (SQLException ex) { diff --git a/src/main/java/knowledgeGraphs/DBLP.java b/src/main/java/knowledgeGraphs/DBLP.java new file mode 100644 index 0000000..3fabde8 --- /dev/null +++ b/src/main/java/knowledgeGraphs/DBLP.java @@ -0,0 +1,429 @@ +package knowledgeGraphs; + +import benchmarkGenerator.subgraphShapeGenerator.model.Variable; +import benchmarkGenerator.subgraphShapeGenerator.model.VariableSet; +import lexiconGenerator.kg_explorer.explorer.Explorer; +import lexiconGenerator.kg_explorer.model.PredicateContext; +import lexiconGenerator.kg_explorer.model.PredicateTripleExample; +import settings.Settings; +import system.components.Branch; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +import static lexiconGenerator.kg_explorer.explorer.Explorer.kg; + +public class DBLP extends KnowledgeGraph { + public DBLP(String endpoint) { + this.endpoint = endpoint; + } + + public static KnowledgeGraph getInstance(String endpoint) { + if (instance == null) { + instance = new DBLP(endpoint); + } + return (DBLP) instance; + } + + @Override + public String[] getUnwantedProperties() { + unwantedProperties = new String[]{ + "http://www.w3.org/2000/01/rdf-schema#label", + "http://www.w3.org/2000/01/rdf-schema#subPropertyOf", + "http://www.w3.org/2000/01/rdf-schema#comment", + "http://www.w3.org/2000/01/rdf-schema#label", + "http://www.w3.org/2000/01/rdf-schema#seeAlso", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", + "http://www.w3.org/2000/01/rdf-schema#subClassOf", + "http://www.w3.org/2000/01/rdf-schema#range", + "http://www.w3.org/2000/01/rdf-schema#domain", + + "http://www.w3.org/2002/07/owl#inverseOf ", + "http://www.w3.org/2000/01/rdf-schema#subPropertyOf", + "http://www.w3.org/2002/07/owl#imports", + + "http://www.w3.org/2002/07/owl#sameAs", + "http://www.w3.org/2002/07/owl#equivalentProperty", + "http://www.w3.org/2002/07/owl#differentFrom", + "http://www.w3.org/2002/07/owl#versionInfo", + "http://www.w3.org/2002/07/owl#disjointWith", + "http://www.w3.org/2002/07/owl#equivalentClass", + "http://www.w3.org/2002/07/owl#complementOf", + + "http://xmlns.com/foaf/0.1/name", + "http://xmlns.com/foaf/0.1/primaryTopic", + + "http://www.openlinksw.com/schemas/virtrdf#loadAs", + "http://www.openlinksw.com/schemas/virtrdf#item", + "http://www.openlinksw.com/schemas/virtrdf#isSpecialPredicate", + "http://www.openlinksw.com/schemas/virtrdf#qmfValRange-rvrRestrictions", + "http://www.openlinksw.com/schemas/virtrdf#qmfSuperFormats", + "http://www.openlinksw.com/schemas/virtrdf#inheritFrom", + "http://www.openlinksw.com/schemas/virtrdf#noInherit", + "http://www.openlinksw.com/schemas/virtrdf#qmfSubFormatForRefs", + "http://www.openlinksw.com/schemas/virtrdf#qmGraphMap", + "http://www.openlinksw.com/schemas/virtrdf#qmSubjectMap", + "http://www.openlinksw.com/schemas/virtrdf#qmPredicateMap", + "http://www.openlinksw.com/schemas/virtrdf#qmObjectMap", + "http://www.openlinksw.com/schemas/virtrdf#qsMatchingFlags", + "http://www.openlinksw.com/schemas/virtrdf#qmvGeo", + "http://www.openlinksw.com/schemas/virtrdf#qmvATables", + "http://www.openlinksw.com/schemas/virtrdf#qmvFormat", + "http://www.openlinksw.com/schemas/virtrdf#qsDefaultMap", + "http://www.openlinksw.com/schemas/virtrdf#qmvFText", + "http://www.openlinksw.com/schemas/virtrdf#qmvftConds", + "http://www.openlinksw.com/schemas/virtrdf#qmMatchingFlags", + "http://www.openlinksw.com/schemas/DAV#ownerUser", + "http://www.openlinksw.com/schemas/virtrdf#qmvColumns", + "http://www.openlinksw.com/schemas/virtrdf#qsUserMaps", + + + "http://www.w3.org/1999/02/22-rdf-syntax-ns#_1", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#_2", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#_3", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#_4", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#_5", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#first", + " http://www.w3.org/ns/sparql-service-description#url", + + "http://purl.org/linguistics/gold/hypernym", + "http://purl.org/dc/terms/title", + "http://purl.org/dc/elements/1.1/title", + "http://purl.org/ontology/mo/biography", + + "http://www.w3.org/2002/07/owl#inverseOf", + }; + return unwantedProperties; + } + + @Override + public ArrayList getPredicateList_EntityObjects(int from, int length) { + String query = "SELECT DISTINCT ?p WHERE { " + + "\n\t?s ?p ?o. " + " \nFilter(isIRI(?o)). " //Get only if ?o is entity + + "\n} LIMIT " + length + " OFFSET " + from; + ArrayList predicatesVariableSet = new ArrayList<>(kg.runQuery(query)); + predicatesVariableSet = new ArrayList<>(new HashSet<>(predicatesVariableSet)); + predicatesVariableSet = filterResult(predicatesVariableSet); + return predicatesVariableSet; + } + + @Override + public ArrayList getPredicatesContext_EntityObjects(String predicateURI) { + String unwantedPropertiesString = kg.getUnwantedPropertiesString(); + long weight = 0; + String query = "PREFIX rdf: \n" + + "PREFIX rdfs: \n" + + "PREFIX owl: \n" + + "PREFIX schema: \n" + + " \n" + + "SELECT DISTINCT ?s_type ?o_type (count(?s) as ?count)\n" + + "WHERE{\n" + + "?s " + predicateURI + " ?o.\n" + + "?s rdf:type ?s_type.\n" + + " ?o rdf:type ?o_type.\n" // + ; + if (Settings.requiredTypePrefix != null && !"".equals(Settings.requiredTypePrefix)) { + query += " FILTER (strstarts(str(?s_type ), str(" + Settings.requiredTypePrefix + "))).\n" + + " FILTER (strstarts(str(?o_type ), str(" + Settings.requiredTypePrefix + "))).\n"; + } + query += "} GROUP BY ?s_type ?o_type " + + " ORDER By (str(?s_type))\n"; + predicatesTriplesVarSets = kg.runQuery(query); + //remove duplicates as sometimes Distinct does not work in the KGMS + predicatesTriplesVarSets = new ArrayList<>(new HashSet<>(predicatesTriplesVarSets)); + + ArrayList predicateContexts = new ArrayList<>(); + for (VariableSet predicate : predicatesTriplesVarSets) { + String stype = predicate.getVariables().get(0).getValueWithPrefix(); + String otype = predicate.getVariables().get(1).getValueWithPrefix(); + String weightString = predicate.getVariables().get(2).getValueWithPrefix(); +// System.out.println("stype:" + stype + ", " + "otype:" + otype); +// weight = getPredicateWeight(predicateURI.replace("<", "").replace(">", ""), stype, otype); + weight = Long.parseLong(weightString); + predicateContexts.add(new PredicateContext(stype, otype, weight)); +// System.out.println(predicate.toString()); + } + System.out.println("Predicate Context list size before filteration: " + predicateContexts.size()); + predicateContexts = filterOutNoisyContexts(predicateContexts); + System.out.println("Predicate Context list size after filteration: " + predicateContexts.size()); + return predicateContexts; + + } + + @Override + public ArrayList getPredicatesContext_NumberObjects(String predicateURI) { + String unwantedPropertiesString = kg.getUnwantedPropertiesString(); + long weight = 0; + String query = "PREFIX rdf: \n" + + "PREFIX rdfs: \n" + + "PREFIX owl: \n" + + "PREFIX schema: \n" + + " \n" + + "SELECT DISTINCT ?s_type (count(?s) as ?count)\n" + // + "SELECT DISTINCT SAMPLE(?s) SAMPLE(?o) ?s_type ?o_type \n" + + "WHERE{\n" + + "?s " + predicateURI + " ?o.\n" + + "?s rdf:type ?s_type.\n" + + "\n"; + + if (Settings.requiredTypePrefix != null && !"".equals(Settings.requiredTypePrefix)) { + query += " FILTER (strstarts(str(?s_type ), str(" + Settings.requiredTypePrefix + "))).\n"; + } + query += "} GROUP BY ?s_type " + + " ORDER By (str(?s_type))\n"; + predicatesTriplesVarSets = kg.runQuery(query); + //remove duplicates as sometimes Distinct does not work in the KGMS + predicatesTriplesVarSets = new ArrayList<>(new HashSet<>(predicatesTriplesVarSets)); + + ArrayList predicateContexts = new ArrayList<>(); + for (VariableSet predicate : predicatesTriplesVarSets) { + String stype = predicate.getVariables().get(0).getValueWithPrefix(); + String otype = "Number"; + String weightString = predicate.getVariables().get(1).getValueWithPrefix(); +// System.out.println("stype:" + stype + ", " + "otype:" + otype); +// weight = getPredicateWeight(predicateURI.replace("<", "").replace(">", ""), stype, otype); + weight = Long.parseLong(weightString); + predicateContexts.add(new PredicateContext(stype, otype, weight)); +// System.out.println(predicate.toString()); + } + System.out.println("Predicate Context list size before filteration: " + predicateContexts.size()); + predicateContexts = filterOutNoisyContexts(predicateContexts); + System.out.println("Predicate Context list size after filteration: " + predicateContexts.size()); + return predicateContexts; + + } + + @Override + public ArrayList getPredicatesContext_DateObjects(String predicateURI) { + String unwantedPropertiesString = kg.getUnwantedPropertiesString(); + long weight = 0; + String query = "PREFIX rdf: \n" + + "PREFIX rdfs: \n" + + "PREFIX owl: \n" + + "PREFIX schema: \n" + + " \n" + + "SELECT DISTINCT ?s_type (count(?s) as ?count)\n" + // + "SELECT DISTINCT SAMPLE(?s) SAMPLE(?o) ?s_type ?o_type \n" + + "WHERE{\n" + + "?s " + predicateURI + " ?o.\n" + + "?s rdf:type ?s_type.\n"; + if (Settings.requiredTypePrefix != null && !"".equals(Settings.requiredTypePrefix)) { + query += " FILTER (strstarts(str(?s_type ), str(" + Settings.requiredTypePrefix + "))).\n"; + } + query += "} GROUP BY ?s_type " + + " ORDER By (str(?s_type))\n"; + predicatesTriplesVarSets = kg.runQuery(query); + //remove duplicates as sometimes Distinct does not work in the KGMS + predicatesTriplesVarSets = new ArrayList<>(new HashSet<>(predicatesTriplesVarSets)); + + ArrayList predicateContexts = new ArrayList<>(); + for (VariableSet predicate : predicatesTriplesVarSets) { + String stype = predicate.getVariables().get(0).getValueWithPrefix(); + String otype = "Date"; + String weightString = predicate.getVariables().get(1).getValueWithPrefix(); +// System.out.println("stype:" + stype + ", " + "otype:" + otype); +// weight = getPredicateWeight(predicateURI.replace("<", "").replace(">", ""), stype, otype); + weight = Long.parseLong(weightString); + predicateContexts.add(new PredicateContext(stype, otype, weight)); +// System.out.println(predicate.toString()); + } + System.out.println("Predicate Context list size before filteration: " + predicateContexts.size()); + predicateContexts = filterOutNoisyContexts(predicateContexts); + System.out.println("Predicate Context list size after filteration: " + predicateContexts.size()); + return predicateContexts; + + } + + @Override + public ArrayList getPredicatesContext_Literals(String predicateURI) { + String unwantedPropertiesString = kg.getUnwantedPropertiesString(); + long weight = 0; + String query = "PREFIX rdf: \n" + + "PREFIX rdfs: \n" + + "PREFIX owl: \n" + + "PREFIX schema: \n" + + " \n" + + "SELECT DISTINCT ?s_type (count(?s) as ?count)\n" + // + "SELECT DISTINCT SAMPLE(?s) SAMPLE(?o) ?s_type ?o_type \n" + + "WHERE{\n" + + "?s " + predicateURI + " ?o.\n" + + "?s rdf:type ?s_type.\n"; + if (Settings.requiredTypePrefix != null && !"".equals(Settings.requiredTypePrefix)) { + query += " FILTER (strstarts(str(?s_type ), str(" + Settings.requiredTypePrefix + "))).\n"; + } + query += "} GROUP BY ?s_type " + + " ORDER By (str(?s_type))\n"; + predicatesTriplesVarSets = kg.runQuery(query); + //remove duplicates as sometimes Distinct does not work in the KGMS + predicatesTriplesVarSets = new ArrayList<>(new HashSet<>(predicatesTriplesVarSets)); + + ArrayList predicateContexts = new ArrayList<>(); + for (VariableSet predicate : predicatesTriplesVarSets) { + String stype = predicate.getVariables().get(0).getValueWithPrefix(); + String otype = "Literal"; + String weightString = predicate.getVariables().get(1).getValueWithPrefix(); +// System.out.println("stype:" + stype + ", " + "otype:" + otype); +// weight = getPredicateWeight(predicateURI.replace("<", "").replace(">", ""), stype, otype); + weight = Long.parseLong(weightString); + predicateContexts.add(new PredicateContext(stype, otype, weight)); +// System.out.println(predicate.toString()); + } + System.out.println("Predicate Context list size before filteration: " + predicateContexts.size()); + predicateContexts = filterOutNoisyContexts(predicateContexts); + System.out.println("Predicate Context list size after filteration: " + predicateContexts.size()); + return predicateContexts; + + } + + @Override + public ArrayList getPredicateContextFromTripleExample(String subjectURI, String predicateURI, String objectURI) { + String unwantedPropertiesString = Settings.knowledgeGraph.getUnwantedPropertiesString(); + long weight = 0; + String query = "PREFIX rdf: \n" + + "PREFIX rdfs: \n" + + "PREFIX owl: \n" + + "PREFIX schema: \n" + + " \n" + + "SELECT DISTINCT ?s_type ?o_type \n" + + "WHERE{\n" + + " <" + subjectURI + "> rdf:type ?s_type.\n" + + " <" + objectURI + "> rdf:type ?o_type.\n" + + " }.\n"; + + if (Settings.requiredTypePrefix != null && !"".equals(Settings.requiredTypePrefix)) { + query += " FILTER strstarts(str(?s_type ), str(" + Settings.requiredTypePrefix + ")).\n" + + " FILTER strstarts(str(?o_type ), str(" + Settings.requiredTypePrefix + ")).\n"; + } + query += "}"; + ArrayList predicatesTriplesVarSets = Settings.knowledgeGraph.runQuery(query); + //remove duplicates as sometimes Distinct does not work in the KGMS + predicatesTriplesVarSets = new ArrayList<>(new HashSet<>(predicatesTriplesVarSets)); + + ArrayList predicateContexts = new ArrayList<>(); + for (VariableSet predicate : predicatesTriplesVarSets) { + String stype = predicate.getVariables().get(0).getValueWithPrefix(); + String otype = predicate.getVariables().get(1).getValueWithPrefix(); + weight = 0; + predicateContexts.add(new PredicateContext(stype, otype, weight)); + } + return predicateContexts; + + } + + @Override + public Branch getBranchOfType_SType_connectTo_OType(Explorer explorer, String S_type, String O_type, String predicateURI, int offset) { + String query = ""; + //get labels + try { + if (O_type.equals("Number") || O_type.equals("Date") || O_type.equals(Settings.Literal)) { + query = "SELECT DISTINCT ?s ?o WHERE {\n " + + " ?s <" + predicateURI + "> ?o. ?s rdf:type <" + S_type + ">." + Settings.popularityFilter + + "\n}\n " + + Settings.popularityORDER + + "OFFSET " + offset; + } else { + query = "SELECT DISTINCT ?s ?o WHERE {\n " + + " ?s <" + predicateURI + "> ?o. ?s rdf:type <" + S_type + ">. ?o rdf:type <" + O_type + ">. " + Settings.popularityFilter + + "\n}\n " + + Settings.popularityORDER + + "OFFSET " + offset; + } + Explorer.predicatesTriplesVarSets = Settings.knowledgeGraph.runQuery(query); + + String s = Explorer.predicatesTriplesVarSets.get(0).getVariables().get(0).toString(); + String o = Explorer.predicatesTriplesVarSets.get(0).getVariables().get(1).toString(); + + return new Branch(s, o, predicateURI, S_type, O_type); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + @Override + public ArrayList getOneTripleExample(String predicate, String sType, String oType, String lable, int noOfExamples) { + String query = ""; + ArrayList predicateTriples = new ArrayList<>(); + try { + if (oType.equals("Number")) { + query = "SELECT DISTINCT ?s ?o WHERE { \n" + + "?s <" + predicate.trim() + "> ?o .\n" + + "?s rdf:type <" + sType + ">. \n" + + "\n"; + //Get only dbpedia types + if (Settings.requiredTypePrefix != null && !"".equals(Settings.requiredTypePrefix)) { + query += " FILTER strstarts(str(<" + sType + "> ), str(" + Settings.requiredTypePrefix + ")).\n"; + } + + query += "FILTER isNumeric(?o)." + + "\n" + + "\n" + + "} LIMIT " + noOfExamples; + } else if (oType.equals("Date")) { + query = "SELECT DISTINCT ?s ?o WHERE { \n" + + "?s <" + predicate.trim() + "> ?o .\n" + + "?s rdf:type <" + sType + ">. \n" + + "\n"; + if (Settings.requiredTypePrefix != null && !"".equals(Settings.requiredTypePrefix)) { + //Get only dbpedia types + query += " FILTER strstarts(str(<" + sType + "> ), str(" + Settings.requiredTypePrefix + ")).\n"; + } + query += " FILTER (datatype(?o) = xsd:dateTime ). \n" + + "\n" + + "\n" + + "} LIMIT " + noOfExamples; + } else { + query = "SELECT DISTINCT ?s ?o WHERE { \n" + + "?s <" + predicate.trim() + "> ?o .\n" + + "?s rdf:type <" + sType + ">. \n" + + "?o rdf:type <" + oType + ">. \n" + + "\n"; + if (Settings.requiredTypePrefix != null && !"".equals(Settings.requiredTypePrefix)) { + //Get only dbpedia types + query += " FILTER strstarts(str(<" + sType + "> ), str(" + Settings.requiredTypePrefix + ")).\n" + + " FILTER strstarts(str(<" + oType + "> ), str(" + Settings.requiredTypePrefix + ")).\n"; + } + query += "\n" + + "\n" + + "} LIMIT " + noOfExamples; + } + predicatesTriplesVarSets = kg.runQuery(query); + if (predicatesTriplesVarSets.size() > noOfExamples) { + predicatesTriplesVarSets = new ArrayList<>(predicatesTriplesVarSets.subList(0, noOfExamples)); + } + for (VariableSet predicate1 : predicatesTriplesVarSets) { + String s = predicate1.getVariables().get(0).toString(); + String o = predicate1.getVariables().get(1).toString(); + PredicateTripleExample predicateTriple = new PredicateTripleExample("<" + s + ">", "<" + o + ">", Settings.explorer.removePrefix(s), Settings.explorer.removePrefix(o), lable, Settings.explorer); + predicateTriples.add(predicateTriple); + //To speed up the system. break after one VP. +// if(predicateTriple.getNlsSuggestionsObjects().size()>=1) +// break; + } + return predicateTriples; + } catch (Exception e) { + return new ArrayList<>(); + } + } + + private ArrayList filterResult( ArrayList result) { + List list = Arrays.asList(this.getUnwantedProperties()); + ArrayList newVariableSetList = new ArrayList<>(); + for (VariableSet set : result) { + VariableSet newSet = new VariableSet(); + ArrayList newVariables = new ArrayList<>(); + for (Variable v : set.getVariables()) { + String value = v.getValueWithPrefix().replace(" ","" ); + if (! list.contains(value) && ! value.contains("/virtrdf")) { + newVariables.add(v); + } + } + newSet.setVariables(newVariables); + newVariableSetList.add(newSet); + } + return newVariableSetList; + } +} diff --git a/src/main/java/settings/Dblp_Settings.java b/src/main/java/settings/Dblp_Settings.java new file mode 100644 index 0000000..b5401a3 --- /dev/null +++ b/src/main/java/settings/Dblp_Settings.java @@ -0,0 +1,45 @@ +package settings; + +import knowledgeGraphs.DBLP; +import knowledgeGraphs.YAGO; +import lexiconGenerator.kg_explorer.explorer.DBLPExplorer; +import lexiconGenerator.kg_explorer.explorer.YagoExplorer; + +public class Dblp_Settings extends Settings { + public static void intializeSetttings() { + Query_SLICING_SIZE = 1500; + benchmarkName = "Smart_dblp_"; + + //Database + databaseName = "dblp"; + databaseURL = "jdbc:postgresql://localhost:5432/"; + databaseUser = "postgres"; + databasePassword = "admin"; + + requiredTypePrefix = null; + unwantedTypes = null; + + maxAnswerCardinalityAllowed = 500; + SET_QUESTION_TOP_ENTITY = 5; //get random value between 1 and this value + + + name = "dblp"; + url = "http://206.12.95.86:8894/sparql"; + default_graph_uri = ""; + + explorer = new DBLPExplorer(url); + explorer = (DBLPExplorer) explorer; + knowledgeGraph = new DBLP(url); + knowledgeGraph = (DBLP) knowledgeGraph; + + Triple_NP_Direction = LABEL_NP_OS; //This means noun labels in dbpedia represent the fact (O is label of S) + //Seed types + Person = ""; + Place = ""; + + popularityFilter = ""; //used in SPARQL Class + popularityORDER = ""; //used in SPARQL Class + mu = 1.2; + } + +} diff --git a/src/main/java/settings/Settings.java b/src/main/java/settings/Settings.java index 099b0bb..b2277b9 100644 --- a/src/main/java/settings/Settings.java +++ b/src/main/java/settings/Settings.java @@ -28,7 +28,8 @@ public class Settings { public static final int NOBEL_ = 3; public static final int GEO_ = 4; public static final int DBTUNE_ = 5; - + public static final int DBLP = 6; + public static byte LABEL_NP_SO = 1; diff --git a/src/main/java/system/components/RandomSeedGenerator.java b/src/main/java/system/components/RandomSeedGenerator.java index b5a4dfa..d49ce0a 100644 --- a/src/main/java/system/components/RandomSeedGenerator.java +++ b/src/main/java/system/components/RandomSeedGenerator.java @@ -46,6 +46,9 @@ public static void generateSeedList(int offset) { i < (offset + 10); // i= typesSize) { + break; + } Predicate p = availablePredicates.get(i); if (p.getPredicateURI().toLowerCase().contains("party")) { diff --git a/src/main/java/system/components/ShapesGenerator.java b/src/main/java/system/components/ShapesGenerator.java index dc09ed3..5eb8cbb 100644 --- a/src/main/java/system/components/ShapesGenerator.java +++ b/src/main/java/system/components/ShapesGenerator.java @@ -53,7 +53,7 @@ public static void generateShapes() throws Exception { int benchmarkNumber = 37; - for (int j = 480; j < 10000; j = j + 10) { + for (int j = 0; j < 10000; j = j + 10) { clearGeneratedQuestions = new ArrayList<>(); generatedQuestions = new ArrayList<>(); diff --git a/src/main/java/system/components/SmartBench.java b/src/main/java/system/components/SmartBench.java index 6496e9d..799f47e 100644 --- a/src/main/java/system/components/SmartBench.java +++ b/src/main/java/system/components/SmartBench.java @@ -12,12 +12,7 @@ import java.util.logging.Logger; import org.apache.jena.base.Sys; -import settings.Configuration; -import settings.DBpedia_Settings; -import settings.DBtune_Settings; -import settings.GEO_Settings; -import settings.MAKG_Settings; -import settings.Nobel_Settings; +import settings.*; /** * @@ -40,14 +35,17 @@ public static void main(String[] args) { MAKG_Settings.intializeSetttings(); break; case "NOBEL": - GEO_Settings.intializeSetttings(); + Nobel_Settings.intializeSetttings(); break; case "GEOData": - Nobel_Settings.intializeSetttings(); + GEO_Settings.intializeSetttings(); break; case "DBTune": DBtune_Settings.intializeSetttings(); break; + case "DBLP": + Dblp_Settings.intializeSetttings(); + break; } Scanner in = new Scanner(System.in); @@ -118,6 +116,7 @@ private static void lood_conf_file() { Configuration.kg_name = prop.getProperty("kg_name"); + Configuration.Database_Intializer = prop.getProperty("Database_Intializer").trim().equals("1"); Configuration.Predicate_Extractor = prop.getProperty("Predicate_Extractor").trim().equals("1"); Configuration.NLP_Pattern_Extractor_Text_Corpus = prop.getProperty("NLP_Pattern_Extractor_Text_Corpus").trim().equals("1"); Configuration.Predicate_Representations_Labels = prop.getProperty("Predicate_Representations_Labels").trim().equals("1"); diff --git a/src/main/resources/conf.properties b/src/main/resources/conf.properties index 09df6a5..93f8958 100644 --- a/src/main/resources/conf.properties +++ b/src/main/resources/conf.properties @@ -1,4 +1,4 @@ -# Currently we support the following 1- DBPedia 2-MAKG 3-NOBEL 4-GEOData 5-DBTune +# Currently we support the following 1- DBPedia 2-MAKG 3-NOBEL 4-GEOData 5-DBTune 6-DBLP kg_name = DBPedia #Maestro system components (Generating Lexicons subsystem). If the value is 1, the system will run the correcsponding component.