Example usage for edu.stanford.nlp.util StringUtils find

List of usage examples for edu.stanford.nlp.util StringUtils find

Introduction

In this page you can find the example usage for edu.stanford.nlp.util StringUtils find.

Prototype

public static boolean find(String str, String regex) 

Source Link

Document

Say whether this regular expression can be found inside this String.

Usage

From source file:opennlp.tools.jsmlearning.JSMLearnerOnLatticeWithDeduction.java

License:Apache License

public Pair<List<String>, List<String>> reGroupByOccurrenceOfSeparationKeyword(List<String> posTexts,
        List<String> negTexts, String[] keywords) {
    List<String> posTextsNew = new ArrayList<String>(), negTextsNew = new ArrayList<String>();
    for (String posText : posTexts) {
        Boolean multiwordOccurs = true;
        for (String keyword : keywords) {
            if (!StringUtils.find(posText, keyword))
                multiwordOccurs = false;
            break;
        }/* w ww  . ja v a2  s .  c  o  m*/
        if (multiwordOccurs)
            posTextsNew.add(posText);
        else
            negTextsNew.add(posText);
    }
    for (String negText : negTexts) {
        Boolean multiwordOccurs = true;
        for (String keyword : keywords) {
            if (!StringUtils.find(negText, keyword))
                multiwordOccurs = false;
            break;
        }
        if (multiwordOccurs)
            posTextsNew.add(negText);
        else
            negTextsNew.add(negText);
    }

    return new Pair<List<String>, List<String>>(posTextsNew, negTextsNew);
}