datapreparation.language
Class LanguageDecider

java.lang.Object
  extended by datapreparation.language.LanguageDecider

public class LanguageDecider
extends java.lang.Object

A class that decides the Language of a document (news)

Author:
trondoiv

Field Summary
static int ENGLISH
          A static integer for the English most common words
static int NORWEGIAN
          A static integer for the French most common words
static int UNDECIDED
          A static integer if the language is undecided
 
Constructor Summary
LanguageDecider()
          A constructor for the class.
 
Method Summary
 int checkSentenceInLanguage(java.lang.String sentence)
          A method that checks which language a given sentence is.
 java.lang.String getEngDefaultName()
          Retrieves the filname of the most common words in English.
 java.lang.String getNorDefaultName()
          Retrieves the filname of the most common words in Norwegian.
 boolean loadEng(java.lang.String filename)
          A method that loads a file of the most common English words, and puts them in the HashMap
 boolean loadNor(java.lang.String filename)
          A method that loads a file of the most common French words, and puts them in the HashMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENGLISH

public static final int ENGLISH
A static integer for the English most common words

See Also:
Constant Field Values

NORWEGIAN

public static final int NORWEGIAN
A static integer for the French most common words

See Also:
Constant Field Values

UNDECIDED

public static final int UNDECIDED
A static integer if the language is undecided

See Also:
Constant Field Values
Constructor Detail

LanguageDecider

public LanguageDecider()
A constructor for the class. Loads the most common words files of the three languages.

Method Detail

getEngDefaultName

public java.lang.String getEngDefaultName()
Retrieves the filname of the most common words in English.

Returns:
the English default filename for most common words.

getNorDefaultName

public java.lang.String getNorDefaultName()
Retrieves the filname of the most common words in Norwegian.

Returns:
the Norwegian default filename for most common words.

loadEng

public boolean loadEng(java.lang.String filename)
A method that loads a file of the most common English words, and puts them in the HashMap

Parameters:
filename - the filename of the most common words in English
Returns:
Return true if load is ok, false otherwise

loadNor

public boolean loadNor(java.lang.String filename)
A method that loads a file of the most common French words, and puts them in the HashMap

Parameters:
filename - the filename of the most common words in French
Returns:
Return true if load is ok, false otherwise

checkSentenceInLanguage

public int checkSentenceInLanguage(java.lang.String sentence)
A method that checks which language a given sentence is. The sentence is the title in a txt-document.

Parameters:
sentence - the sentence
Returns:
the language of the document