Skip to content

Commit

Permalink
Loading of configuration files works now also while packaging AGDISTI…
Browse files Browse the repository at this point in the history
…S to a war
  • Loading branch information
RicardoUsbeck committed Sep 18, 2014
1 parent e086a2e commit 2267bef
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 32 deletions.
3 changes: 1 addition & 2 deletions src/main/java/org/aksw/agdistis/algorithm/CandidateUtil.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -14,15 +13,15 @@ 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");

loadCorporationAffixes(file);
}

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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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");

Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/aksw/agdistis/algorithm/NEDAlgo_HITS.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
Expand Down
23 changes: 11 additions & 12 deletions src/main/java/org/aksw/agdistis/util/TripleIndex.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Triple> search(String subject, String predicate, String object) {
Expand Down Expand Up @@ -115,8 +114,8 @@ public List<Triple> search(String subject, String predicate, String object, int
}

public void close() throws IOException {
ireader.close();
directory.close();
ireader.close();
directory.close();
}

public DirectoryReader getIreader() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2267bef

Please sign in to comment.