Search in sources :

Example 1 with TextualImpl

use of org.opencastproject.metadata.mpeg7.TextualImpl in project opencast by opencast.

the class DictionaryServiceImpl method cleanUpText.

/**
 * Filter the text according to the rules defined by the dictionary
 * implementation used. This implementation uses a regular expression to find
 * matching terms.
 *
 * @return filtered text
 */
@Override
public Textual cleanUpText(String text) {
    logger.debug("Text input: “{}”", text);
    LinkedList<String> words = new LinkedList<String>();
    Matcher matcher = compilesPattern.matcher(text);
    while (matcher.find()) {
        words.add(matcher.group());
    }
    String result = org.apache.commons.lang3.StringUtils.join(words, " ");
    logger.debug("Resulting text: “{}”", result);
    if ("".equals(result)) {
        return null;
    }
    return new TextualImpl(result);
}
Also used : Matcher(java.util.regex.Matcher) TextualImpl(org.opencastproject.metadata.mpeg7.TextualImpl) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 Matcher (java.util.regex.Matcher)1 TextualImpl (org.opencastproject.metadata.mpeg7.TextualImpl)1