diff --git a/src/main/java/org/aksw/agdistis/algorithm/CandidateUtil.java b/src/main/java/org/aksw/agdistis/algorithm/CandidateUtil.java index 961091d..918527a 100644 --- a/src/main/java/org/aksw/agdistis/algorithm/CandidateUtil.java +++ b/src/main/java/org/aksw/agdistis/algorithm/CandidateUtil.java @@ -1,6 +1,5 @@ package org.aksw.agdistis.algorithm; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -32,7 +31,7 @@ public class CandidateUtil { public CandidateUtil() throws IOException { Properties prop = new Properties(); - InputStream input = new FileInputStream("config/agdistis.properties"); + InputStream input = CandidateUtil.class.getResourceAsStream("/config/agdistis.properties"); prop.load(input); this.nodeType = prop.getProperty("nodeType"); diff --git a/src/main/java/org/aksw/agdistis/algorithm/CorporationAffixCleaner.java b/src/main/java/org/aksw/agdistis/algorithm/CorporationAffixCleaner.java index 5243949..010c01b 100644 --- a/src/main/java/org/aksw/agdistis/algorithm/CorporationAffixCleaner.java +++ b/src/main/java/org/aksw/agdistis/algorithm/CorporationAffixCleaner.java @@ -1,10 +1,9 @@ package org.aksw.agdistis.algorithm; import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.FileReader; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.util.HashSet; import java.util.Properties; @@ -14,7 +13,7 @@ public class CorporationAffixCleaner { public CorporationAffixCleaner() throws IOException { Properties prop = new Properties(); - InputStream input = new FileInputStream("config/agdistis.properties"); + InputStream input = CorporationAffixCleaner.class.getResourceAsStream("/config/agdistis.properties"); prop.load(input); String file = prop.getProperty("corporationAffixes"); @@ -22,7 +21,7 @@ public CorporationAffixCleaner() throws IOException { } private void loadCorporationAffixes(String file) throws IOException { - BufferedReader br = new BufferedReader(new FileReader(file)); + BufferedReader br = new BufferedReader(new InputStreamReader(CorporationAffixCleaner.class.getResourceAsStream(file))); while (br.ready()) { String line = br.readLine(); corporationAffixes.add(line); diff --git a/src/main/java/org/aksw/agdistis/algorithm/DomainWhiteLister.java b/src/main/java/org/aksw/agdistis/algorithm/DomainWhiteLister.java index c5ef51d..6c40c6f 100644 --- a/src/main/java/org/aksw/agdistis/algorithm/DomainWhiteLister.java +++ b/src/main/java/org/aksw/agdistis/algorithm/DomainWhiteLister.java @@ -1,10 +1,9 @@ package org.aksw.agdistis.algorithm; import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.FileReader; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.util.HashSet; import java.util.List; import java.util.Properties; @@ -18,7 +17,7 @@ public class DomainWhiteLister { public DomainWhiteLister(TripleIndex index) throws IOException { Properties prop = new Properties(); - InputStream input = new FileInputStream("config/agdistis.properties"); + InputStream input =DomainWhiteLister.class.getResourceAsStream("/config/agdistis.properties"); prop.load(input); String file = prop.getProperty("whiteList"); @@ -28,7 +27,7 @@ public DomainWhiteLister(TripleIndex index) throws IOException { } private void loadWhiteDomains(String file) throws IOException { - BufferedReader br = new BufferedReader(new FileReader(file)); + BufferedReader br = new BufferedReader(new InputStreamReader(DomainWhiteLister.class.getResourceAsStream(file))); while (br.ready()) { String line = br.readLine(); whiteList.add(line); diff --git a/src/main/java/org/aksw/agdistis/algorithm/NEDAlgo_HITS.java b/src/main/java/org/aksw/agdistis/algorithm/NEDAlgo_HITS.java index 1fd0fc9..a0b1b22 100644 --- a/src/main/java/org/aksw/agdistis/algorithm/NEDAlgo_HITS.java +++ b/src/main/java/org/aksw/agdistis/algorithm/NEDAlgo_HITS.java @@ -1,6 +1,5 @@ package org.aksw.agdistis.algorithm; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -36,7 +35,7 @@ public class NEDAlgo_HITS { public NEDAlgo_HITS() throws IOException { Properties prop = new Properties(); - InputStream input = new FileInputStream("config/agdistis.properties"); + InputStream input = NEDAlgo_HITS.class.getResourceAsStream("/config/agdistis.properties"); prop.load(input); String nodeType = prop.getProperty("nodeType"); diff --git a/src/main/java/org/aksw/agdistis/util/TripleIndex.java b/src/main/java/org/aksw/agdistis/util/TripleIndex.java index a3abca9..6aa7177 100644 --- a/src/main/java/org/aksw/agdistis/util/TripleIndex.java +++ b/src/main/java/org/aksw/agdistis/util/TripleIndex.java @@ -1,7 +1,6 @@ package org.aksw.agdistis.util; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -45,17 +44,17 @@ public class TripleIndex { private UrlValidator urlValidator; public TripleIndex() throws IOException { - Properties prop = new Properties(); - InputStream input = new FileInputStream("config/agdistis.properties"); - prop.load(input); + Properties prop = new Properties(); + InputStream input = TripleIndex.class.getResourceAsStream("/config/agdistis.properties"); + prop.load(input); - String index = prop.getProperty("index"); - log.info("The index will be here: " + index); + String index = prop.getProperty("index"); + log.info("The index will be here: " + index); - directory = new MMapDirectory(new File(index)); - ireader = DirectoryReader.open(directory); - isearcher = new IndexSearcher(ireader); - this.urlValidator = new UrlValidator(); + directory = new MMapDirectory(new File(index)); + ireader = DirectoryReader.open(directory); + isearcher = new IndexSearcher(ireader); + this.urlValidator = new UrlValidator(); } public List search(String subject, String predicate, String object) { @@ -115,8 +114,8 @@ public List search(String subject, String predicate, String object, int } public void close() throws IOException { - ireader.close(); - directory.close(); + ireader.close(); + directory.close(); } public DirectoryReader getIreader() { diff --git a/config/agdistis.de.properties b/src/main/resources/config/agdistis.de.properties similarity index 91% rename from config/agdistis.de.properties rename to src/main/resources/config/agdistis.de.properties index 67df770..1d68ee8 100644 --- a/config/agdistis.de.properties +++ b/src/main/resources/config/agdistis.de.properties @@ -15,8 +15,8 @@ threshholdTrigram=0.82 #heuristicExpansionOn explains whether simple coocurence resolution is done or not, e.g., Barack => Barack Obama if both are in the same text heuristicExpansionOn=false #list of entity domains and corporationAffixes -whiteList=config/whiteList.txt -corporationAffixes=config/corporationAffixes.txt +whiteList=/config/whiteList.txt +corporationAffixes=/config/corporationAffixes.txt # IMPORTANT for creating an own index folderWithTTLFiles=/data/r.usbeck/DBpedia/2014_de diff --git a/config/agdistis.en.properties b/src/main/resources/config/agdistis.en.properties similarity index 91% rename from config/agdistis.en.properties rename to src/main/resources/config/agdistis.en.properties index 149284a..a4d845c 100644 --- a/config/agdistis.en.properties +++ b/src/main/resources/config/agdistis.en.properties @@ -15,8 +15,8 @@ threshholdTrigram=0.82 #heuristicExpansionOn explains whether simple coocurence resolution is done or not, e.g., Barack => Barack Obama if both are in the same text heuristicExpansionOn=false #list of entity domains and corporationAffixes -whiteList=config/whiteList.txt -corporationAffixes=config/corporationAffixes.txt +whiteList=/config/whiteList.txt +corporationAffixes=/config/corporationAffixes.txt # IMPORTANT for creating an own index folderWithTTLFiles=/data/r.usbeck/DBpedia/2014_en diff --git a/config/agdistis.properties b/src/main/resources/config/agdistis.properties similarity index 91% rename from config/agdistis.properties rename to src/main/resources/config/agdistis.properties index 149284a..a4d845c 100644 --- a/config/agdistis.properties +++ b/src/main/resources/config/agdistis.properties @@ -15,8 +15,8 @@ threshholdTrigram=0.82 #heuristicExpansionOn explains whether simple coocurence resolution is done or not, e.g., Barack => Barack Obama if both are in the same text heuristicExpansionOn=false #list of entity domains and corporationAffixes -whiteList=config/whiteList.txt -corporationAffixes=config/corporationAffixes.txt +whiteList=/config/whiteList.txt +corporationAffixes=/config/corporationAffixes.txt # IMPORTANT for creating an own index folderWithTTLFiles=/data/r.usbeck/DBpedia/2014_en diff --git a/config/agdistis.zh.properties b/src/main/resources/config/agdistis.zh.properties similarity index 90% rename from config/agdistis.zh.properties rename to src/main/resources/config/agdistis.zh.properties index 9bcae83..34d5eb5 100644 --- a/config/agdistis.zh.properties +++ b/src/main/resources/config/agdistis.zh.properties @@ -15,8 +15,8 @@ threshholdTrigram=0.82 #heuristicExpansionOn explains whether simple coocurence resolution is done or not, e.g., Barack => Barack Obama if both are in the same text heuristicExpansionOn=false #list of entity domains and corporationAffixes -whiteList=config/whiteList.txt -corporationAffixes=config/corporationAffixes.txt +whiteList=/config/whiteList.txt +corporationAffixes=/config/corporationAffixes.txt # IMPORTANT for creating an own index folderWithTTLFiles=/data/r.usbeck/DBpedia/2014_zh diff --git a/config/corporationAffixes.txt b/src/main/resources/config/corporationAffixes.txt similarity index 100% rename from config/corporationAffixes.txt rename to src/main/resources/config/corporationAffixes.txt diff --git a/config/whiteList.txt b/src/main/resources/config/whiteList.txt similarity index 100% rename from config/whiteList.txt rename to src/main/resources/config/whiteList.txt diff --git a/config/whiteListYago.txt b/src/main/resources/config/whiteListYago.txt similarity index 100% rename from config/whiteListYago.txt rename to src/main/resources/config/whiteListYago.txt