org.ow2.weblab.service.language
Class NGramProfilesPatched
java.lang.Object
org.ow2.weblab.service.language.NGramProfilesPatched
public class NGramProfilesPatched
- extends java.lang.Object
This is a patched version of NGramProfiles class from CNGram project.
It has been added to enable the use of custom language models. When using the default version, it's only possible to load languages models that are present in the jar, next to the NGramProfiles
class. We only copy-paste the code, add the right behaviour by adding a constructor and an init method on a folder (containing language models). We also removed some warning by changing the access
right on some fields and qualifying accesses with this. We also handle generics when possible. And last but not least, we change the code of original loading method to use the same ClassLoader than
before (i.e. original NGramProfiles one).
"Manage a set of profiles and determine "most similar" ones to a given profile. Allows access to the complete results of previous last ranking. Note this uses a competetive ranking approach, which is memory efficient, time efficient for not too many languages and provides contextual scoring of ngrams."
- Author:
- Inspired from frank nestel, EADS IPCC Team
- See Also:
NGramProfiles
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NOLANGNAME
public static final java.lang.String NOLANGNAME
- See Also:
- Constant Field Values
END_CHAR
public static final char END_CHAR
- See Also:
- Constant Field Values
DF
public static final java.text.DecimalFormat DF
LOWSTATSAFETY
public static final double LOWSTATSAFETY
- See Also:
- Constant Field Values
NGramProfilesPatched
public NGramProfilesPatched()
throws java.io.IOException
- Throws:
java.io.IOException
NGramProfilesPatched
public NGramProfilesPatched(int mode)
throws java.io.IOException
- Throws:
java.io.IOException
NGramProfilesPatched
public NGramProfilesPatched(java.io.BufferedReader br)
throws java.io.IOException
- Throws:
java.io.IOException
NGramProfilesPatched
public NGramProfilesPatched(java.io.File folder)
throws java.io.IOException
- Throws:
java.io.IOException
getRanker
public NGramProfilesPatched.Ranker getRanker()
getProfileName
public java.lang.String getProfileName(int i)
charAt
public static final char charAt(java.lang.CharSequence cs,
int pos)
rank
public NGramProfilesPatched.RankResult rank(de.spieleck.app.cngram.NGramMetric metric,
de.spieleck.app.cngram.NGramProfile profile)
- Note this class returns a complete match result, for the
sake of thread safety!
getProfileCount
public int getProfileCount()
getAllNGrams
public java.util.Set<de.spieleck.app.cngram.NGram> getAllNGrams()
init
protected void init(java.io.File folder)
throws java.io.IOException
- Throws:
java.io.IOException
Copyright © 2004-2012. All Rights Reserved.