Example usage for edu.stanford.nlp.ie NERClassifierCombiner NERClassifierCombiner

List of usage examples for edu.stanford.nlp.ie NERClassifierCombiner NERClassifierCombiner

Introduction

In this page you can find the example usage for edu.stanford.nlp.ie NERClassifierCombiner NERClassifierCombiner.

Prototype

@SafeVarargs
    public NERClassifierCombiner(AbstractSequenceClassifier<CoreLabel>... classifiers) throws IOException 

Source Link

Usage

From source file:lv.lumii.ner.analysis.ClassifierComparator.java

License:Open Source License

void addClassifier(List<AbstractSequenceClassifier<CoreLabel>> classifiers) throws FileNotFoundException {
    NERClassifierCombiner ncc = new NERClassifierCombiner(classifiers);
    addClassifier(ncc);//from  w  w w  .  ja v  a2  s .c  o  m
}

From source file:lv.lumii.ner.NerPipe.java

License:Open Source License

@SuppressWarnings("unchecked")
public NerPipe(Properties props) throws ClassCastException, ClassNotFoundException, IOException {
    this.props = props;
    initializeFromProperties();//from w  w w.  ja  va 2 s.com

    List<AbstractSequenceClassifier<CoreLabel>> classifiers = new ArrayList<>();

    if (props.containsKey("whiteListCasedLemmas"))
        classifiers.add(
                new ListNERSequenceClassifier(props.getProperty("whiteListUncasedLemmas"), false, true, true));
    if (props.containsKey("whiteListUncasedWords"))
        classifiers.add(
                new ListNERSequenceClassifier(props.getProperty("whiteListUncasedWords"), true, false, true));
    if (props.containsKey("whiteListCasedWords"))
        classifiers.add(
                new ListNERSequenceClassifier(props.getProperty("whiteListCasedWords"), false, false, true));
    if (defaultCrfClassifier != null)
        classifiers.add(CRFClassifier.getClassifier(defaultCrfClassifier, props));
    if (props.containsKey("regexList"))
        classifiers.add(new RegexNERSequenceClassifier(props.getProperty("regexList"), true, true));

    classifier = new NERClassifierCombiner(classifiers);
    defaultReaderWriter = new LVCoNLLDocumentReaderAndWriter();
    defaultReaderWriter.init(classifier.flags);
}

From source file:lv.lumii.ner.NerPipe.java

License:Open Source License

public NerPipe(Properties props, AbstractSequenceClassifier<CoreLabel> classifier)
        throws FileNotFoundException {
    this(props, new NERClassifierCombiner(classifier));
}

From source file:lv.pipe.NerTagger.java

License:Open Source License

@Override
public void init(Properties props) {
    properties = props;/*from   w ww.  j a  va 2s.c  om*/
    List<AbstractSequenceClassifier<CoreLabel>> classifiers = new ArrayList<>();
    if (props.containsKey("whiteListCasedLemmas"))
        classifiers.add(
                new ListNERSequenceClassifier(props.getProperty("whiteListCasedLemmas"), false, true, true));
    if (props.containsKey("whiteListUncasedWords"))
        classifiers.add(
                new ListNERSequenceClassifier(props.getProperty("whiteListUncasedWords"), true, false, true));
    if (props.containsKey("whiteListCasedWords"))
        classifiers.add(
                new ListNERSequenceClassifier(props.getProperty("whiteListCasedWords"), false, false, true));
    if (props.containsKey("loadClassifier")) {
        Properties crfProps = new Properties();
        for (@SuppressWarnings("rawtypes")
        Enumeration propertyNames = props.propertyNames(); propertyNames.hasMoreElements();) {
            Object key = propertyNames.nextElement();
            if (key.equals("whiteListCasedLemmas"))
                continue;
            if (key.equals("whiteListUncasedWords"))
                continue;
            if (key.equals("whiteListCasedWords"))
                continue;
            if (key.equals("regexList"))
                continue;
            crfProps.put(key, props.get(key));
        }
        System.err.println(crfProps);
        try {
            classifiers.add(CRFClassifier.getClassifier(crfProps.getProperty("loadClassifier"), crfProps));
        } catch (ClassCastException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    if (props.containsKey("regexList"))
        classifiers.add(new RegexNERSequenceClassifier(props.getProperty("regexList"), true, true));
    try {
        nerClassifier = new NERClassifierCombiner(classifiers);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}