本文整理汇总了Java中edu.stanford.nlp.ie.crf.CRFClassifier.getClassifierNoExceptions方法的典型用法代码示例。如果您正苦于以下问题:Java CRFClassifier.getClassifierNoExceptions方法的具体用法?Java CRFClassifier.getClassifierNoExceptions怎么用?Java CRFClassifier.getClassifierNoExceptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.ie.crf.CRFClassifier
的用法示例。
在下文中一共展示了CRFClassifier.getClassifierNoExceptions方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preprocess
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
public Concept preprocess(Concept c) {
if (this.tagger == null)
this.tagger = new MaxentTagger("ext_models/pos_tagger/english-left3words-distsim.tagger");
if (this.ner == null)
this.ner = CRFClassifier.getClassifierNoExceptions("ext_models/ner/english.all.3class.distsim.crf.ser.gz");
List<CoreLabel> words = tokFactory.getTokenizer(new StringReader(c.name)).tokenize();
tagger.tagCoreLabels(words);
words = ner.classifySentence(words);
words = this.addLemmas(words);
List<PToken> tokens = new ArrayList<PToken>();
for (CoreLabel word : words) {
PToken t = new PToken(word.originalText());
t.pos = word.tag();
t.neTag = word.get(CoreAnnotations.AnswerAnnotation.class);
t.lemma = word.get(LemmaAnnotation.class);
tokens.add(t);
}
c.tokenList = tokens;
return c;
}
示例2: CRF
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
public static void CRF() {
// Classifer
CRFClassifier<CoreMap> crf
= CRFClassifier.getClassifierNoExceptions(
"C:/Current Books in Progress/NLP and Java/Models"
+ "/english.all.3class.distsim.crf.ser.gz");
String S1 = "Good afternoon Rajat Raina, how are you today?";
String S2 = "I go to school at Stanford University, which is located in California.";
System.out.println(crf.classifyToString(S1));
System.out.println(crf.classifyWithInlineXML(S2));
System.out.println(crf.classifyToString(S2, "xml", true));
Object classification[] = crf.classify(S2).toArray();
for (int i = 0; i < classification.length; i++) {
System.out.println(classification[i]);
}
}
示例3: NERHelper
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
public NERHelper() {
super();
try {
this.classifier = CRFClassifier
.getClassifierNoExceptions(Constants.serializedClassifier);
dbBuilderFactory = DocumentBuilderFactory.newInstance();
dBuilder = dbBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
}
示例4: init
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
@Override
public void init() throws ServletException
{
String modelPath = getServletContext().getRealPath("models/slovenian.ser.gz");
classifier = CRFClassifier.getClassifierNoExceptions(modelPath);
mapper = new ObjectMapper();
}
示例5: getClassifier
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
/**
* @return a singleton classifier
*/
public static final CRFClassifier<CoreLabel> getClassifier() {
if (classifier == null) {
classifier = CRFClassifier
.getClassifierNoExceptions(serializedClassifier);
}
return classifier;
}
示例6: loadModel
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
private void loadModel(String segLoc) {
if (VERBOSE) {
timer.start();
System.err.print("Loading Segmentation Model ["+segLoc+"]...");
}
segmenter = CRFClassifier.getClassifierNoExceptions(segLoc);
if (VERBOSE) {
timer.stop("done.");
}
}
示例7: initNER
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
public void initNER() {
String serializedClassifier = "data/chinese.misc.distsim.crf.ser.gz";
if (ner == null) {
ner = CRFClassifier.getClassifierNoExceptions(serializedClassifier);
}
}
示例8: getClassifier
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
private static AbstractSequenceClassifier<CoreLabel> getClassifier() {
String serializedClassifier = "Files/english.all.3class.distsim.crf.ser.gz";
AbstractSequenceClassifier<CoreLabel> classifier = CRFClassifier
.getClassifierNoExceptions(serializedClassifier);
return classifier;
}
示例9: EntitiesExtractor
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
public EntitiesExtractor(String serializedClassifier) {
classifier = CRFClassifier.getClassifierNoExceptions(serializedClassifier);
}
示例10: EnglishStanfordNERParser
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
/**
* Default protected constructor
*
*/
public EnglishStanfordNERParser() {
String classifierPath = "res/en/english.all.3class.distsim.crf.ser.gz";
classifier = CRFClassifier.getClassifierNoExceptions(classifierPath);
}
示例11: StanfordNER
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
/**
* Constructor which handles an commited Classifier Filename
* @param clfFilename
*/
public StanfordNER(String clfFilename)
{
serializedClassifier = clfFilename;
classifier = CRFClassifier.getClassifierNoExceptions(serializedClassifier);
}
示例12: Index
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
public Index(String classifierFile) {
this.classifier = CRFClassifier.getClassifierNoExceptions(classifierFile);
}
示例13: getClassifier
import edu.stanford.nlp.ie.crf.CRFClassifier; //导入方法依赖的package包/类
/**
* Gets the classifier to use for parsing text
*
* @param config
* The configuration object containing information about which classifier to use.
* @return The classifier to use for extracting entities.
*/
private AbstractSequenceClassifier<CoreLabel> getClassifier(String classifierStr) {
URL classifierURL = Resources.getResource(classifierStr);
AbstractSequenceClassifier<CoreLabel> classifier =
CRFClassifier.getClassifierNoExceptions(classifierURL.getPath());
return classifier;
}