Java Code Examples for edu.stanford.nlp.ie.crf.CRFClassifier#getClassifier()
The following examples show how to use
edu.stanford.nlp.ie.crf.CRFClassifier#getClassifier() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StanfordChineseNER.java From ambiverse-nlu with Apache License 2.0 | 5 votes |
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); expectedSuccessdingTags.put("GPE", "GPE"); expectedSuccessdingTags.put("I-GPE", "I-GPE"); expectedSuccessdingTags.put("B-GPE", "I-GPE"); expectedSuccessdingTags.put("LOC", "LOC"); expectedSuccessdingTags.put("I-LOC", "I-LOC"); expectedSuccessdingTags.put("B-LOC", "I-LOC"); expectedSuccessdingTags.put("PERSON", "PERSON"); expectedSuccessdingTags.put("I-PER", "I-PER"); expectedSuccessdingTags.put("B-PER", "I-PER"); expectedSuccessdingTags.put("ORG", "ORG"); expectedSuccessdingTags.put("I-ORG", "I-ORG"); expectedSuccessdingTags.put("B-ORG", "I-ORG"); expectedSuccessdingTags.put("MISC", "MISC"); expectedSuccessdingTags.put("I-MISC", "I-MISC"); expectedSuccessdingTags.put("B-MISC", "I-MISC"); try { Properties props = ClassPathUtils.getPropertiesFromClasspath("edu/stanford/nlp/models/ner/chinese.kbp.distsim.prop"); props.put("ner.useSUTime", "false"); //false not for english props.put("ner.applyNumericClassifiers", "false"); //false not for english props.put("mergeTags", "false"); classifier = CRFClassifier.getClassifier("edu/stanford/nlp/models/ner/chinese.kbp.distsim.crf.ser.gz", props); } catch (IOException | ClassNotFoundException e) { throw new ResourceInitializationException(e); } }
Example 2
Source File: StanfordQuery.java From Library with MIT License | 5 votes |
public StanfordQuery() { try { LOGGER.debug("Classifier loading started"); ClassLoader classLoader = LibraryServicesImpl.class.getClassLoader(); File file = new File(classLoader.getResource("nlp/english.all.3class.distsim.crf.ser.gz").getFile()); this.classifier = CRFClassifier.getClassifier(file); LOGGER.debug("Classifier loaded successfully"); } catch (Exception e) { LOGGER.error("Error while loading classifier", e); } }
Example 3
Source File: NERThreadLocalService.java From aliada-tool with GNU General Public License v3.0 | 5 votes |
protected AbstractSequenceClassifier<CoreLabel> initialValue() { try { return CRFClassifier.getClassifier(classifierFilePath); } catch (final Exception exception) { LOGGER.error(MessageCatalog._00052_CLASSIFIER_LOAD_FAILURE, classifierFilePath); return NULL_OBJECT_CLASSIFIER; } }
Example 4
Source File: NERSingletonService.java From aliada-tool with GNU General Public License v3.0 | 5 votes |
@Override AbstractSequenceClassifier<CoreLabel> classifier() { synchronized(this) { if (classifier == null) { try { classifier = CRFClassifier.getClassifier(classifierFilePath); } catch (final Exception exception) { LOGGER.error(MessageCatalog._00052_CLASSIFIER_LOAD_FAILURE, classifierFilePath); classifier = NULL_OBJECT_CLASSIFIER; } } return classifier; } }
Example 5
Source File: StanfordNeTagger.java From OpenEphyra with GNU General Public License v2.0 | 5 votes |
/** * Initializes the StanfordNeTagger with a custom model. * * @param customSerializedClassifier path of the custom classifier to load */ public static boolean init(String customSerializedClassifier) { try { classifier = CRFClassifier.getClassifier(customSerializedClassifier); serializedClassifier = customSerializedClassifier; return true; } catch (Exception e) { return false; } }
Example 6
Source File: StanfordNamedEntityExtractor.java From CLIFF with Apache License 2.0 | 5 votes |
private AbstractSequenceClassifier<CoreMap> recognizerForFiles(String NERmodel, String NERprop) throws IOException, ClassCastException, ClassNotFoundException { InputStream mpis = this.getClass().getClassLoader().getResourceAsStream("models/" + NERprop); Properties mp = new Properties(); mp.load(mpis); AbstractSequenceClassifier<CoreMap> recognizer = (AbstractSequenceClassifier<CoreMap>) CRFClassifier.getClassifier("models/" + NERmodel, mp); return recognizer; }