Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Commit

Permalink
fix classloading issues with LanguageIdentifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Newson committed Apr 1, 2009
1 parent 55b0d79 commit 4840eb7
Show file tree
Hide file tree
Showing 20 changed files with 9 additions and 9 deletions.
Expand Up @@ -43,7 +43,7 @@
public class LanguageIdentifier {

private final static int DEFAULT_ANALYSIS_LENGTH = 0; // 0 means full
// content
// content

private final static float SCORE_THRESOLD = 0.00F;

Expand Down Expand Up @@ -96,9 +96,11 @@ public LanguageIdentifier() {
// Gets the value of the maximum size of data to analyze
analyzeLength = DEFAULT_ANALYSIS_LENGTH;

final ClassLoader classLoader = LanguageIdentifier.class.getClassLoader();

Properties p = new Properties();
try {
p.load(this.getClass().getResourceAsStream("langmappings.properties"));
p.load(classLoader.getResourceAsStream("nutch/langmappings.properties"));

Enumeration alllanguages = p.keys();

Expand All @@ -112,8 +114,7 @@ public LanguageIdentifier() {
while (alllanguages.hasMoreElements()) {
String lang = (String) (alllanguages.nextElement());

InputStream is = this.getClass().getClassLoader().getResourceAsStream(
"org/apache/nutch/analysis/lang/" + lang + "." + NGramProfile.FILE_EXTENSION);
InputStream is = classLoader.getResourceAsStream("nutch/" + lang + "." + NGramProfile.FILE_EXTENSION);

if (is != null) {
NGramProfile profile = new NGramProfile(lang, minLength, maxLength);
Expand Down Expand Up @@ -154,13 +155,12 @@ public LanguageIdentifier() {
if (LOG.isInfoEnabled()) {
LOG.info(list.toString());
}
// Create the suspect profile
suspect = new NGramProfile("suspect", minLength, maxLength);
} catch (Exception e) {
if (LOG.isFatalEnabled()) {
LOG.fatal(e.toString());
}
LOG.fatal(e.toString(), e);
}

// Create the suspect profile
suspect = new NGramProfile("suspect", minLength, maxLength);
}

/**
Expand Down

0 comments on commit 4840eb7

Please sign in to comment.