/** * Constructs this NamedEntityRecognizer. * <P> * * @param classifierPath a classifier for Stanford NER * (I am using ner-eng-ie.crf-3-all2008-distsim.ser.gz usually, which * is part of the downloadable Stanford NER package). * */ public StanfordNamedEntityRecognizer(File classifierPath) throws NamedEntityRecognizerException { if (classifierPath.exists()) this.classifierPath = classifierPath; else throw new NamedEntityRecognizerException("File "+classifierPath+" does not exist"); }
public void init() throws NamedEntityRecognizerException { if (initialized) throw new NamedEntityRecognizerException( "init() was called though the StanfordNamedEntityRecognizer was already initialized."); try { this.crfClassifier = CRFClassifier.getClassifier(this.classifierPath.getPath()); this.initialized = true; } catch (Exception e) { throw new NamedEntityRecognizerException("Classifier load failed.",e); } }
public void recognize() throws NamedEntityRecognizerException { if (null==sentence) throw new NamedEntityRecognizerException("null sentence or sentence not set."); this.listOfEntities = new ArrayList<NamedEntityWord>(sentence.size()); this.mapOfEntities = new HashMap<Integer, NamedEntityPhrase>(); for (String word : sentence) { listOfEntities.add(new NamedEntityWord(word, null)); } }
public void recognize() throws NamedEntityRecognizerException throw new NamedEntityRecognizerException("StanfordNamedEntityRecognizer was not initialized."); if (this.sentence==null) throw new NamedEntityRecognizerException("Wrong input to StanfordNamedEntityRecognizer. A null sentence was supplied."); throw new NamedEntityRecognizerException("classifying (i.e. retrieving the Named-Entity for the sentence words) sentence failed.",e); throw new NamedEntityRecognizerException("classification returned a null list");
throw new NamedEntityRecognizerException("Got NER tagging for " + taggedTokens.size() + " tokens, should have gotten according to the total number of tokens in the sentence: " + tokens.size());