|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.nutch.analysis.lang.NGramProfile
This class runs a ngram analysis over submitted text, results might be used for automatic language identifiaction. The similarity calculation is at experimental level. You have been warned. Methods are provided to build new language profiles.
Constructor Summary | |
NGramProfile(String name)
Construct a new ngram profile |
Method Summary | |
void |
addNGrams(StringBuffer word)
Add ngrams to table from a single word |
void |
addNGrams(StringBuffer word,
int n)
add ngram from word, n is submitted |
void |
addToken(Token t)
add token to this profile |
void |
analyze(StringBuffer text)
analyze a piece of text |
static NGramProfile |
createNgramProfile(String name,
InputStream is)
Creates a new Language profile from (preferably quite large) text file |
String |
getName()
|
float |
getSimilarity(NGramProfile another)
Calculates a score how well models do compare This is just an experimental implementation, feel free to enhance |
Vector |
getSorted()
return sorted vector of ngrams (sort done by count) |
void |
load(InputStream is)
Loads a ngram profile from InputStream |
static void |
main(String[] args)
main method used for testing only |
void |
save(OutputStream os)
Writes ngram profile into OutputStream |
void |
setName(String name)
|
String |
toString()
textual representation of this ngramprofile |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public NGramProfile(String name)
name
- Name of profileMethod Detail |
public void addToken(Token t)
t
- Token to be addedpublic void analyze(StringBuffer text)
text
- the text to be analyzedpublic void addNGrams(StringBuffer word)
word
- public void addNGrams(StringBuffer word, int n)
word
- n
- public Vector getSorted()
public String toString()
public float getSimilarity(NGramProfile another)
another
-
public void load(InputStream is) throws IOException
IOException
public static NGramProfile createNgramProfile(String name, InputStream is)
name
- name of profileis
- public void save(OutputStream os) throws IOException
IOException
public static void main(String[] args)
args
- public String getName()
public void setName(String name)
name
- The name to set.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |