Example usage for org.apache.lucene.analysis CharArraySet contains

List of usage examples for org.apache.lucene.analysis CharArraySet contains

Introduction

In this page you can find the example usage for org.apache.lucene.analysis CharArraySet contains.

Prototype

@Override
    public boolean contains(Object o) 

Source Link

Usage

From source file:ca.ualberta.entitylinking.utils.StringUtils.java

License:Open Source License

/**
 * Use the StopAnalyzer.ENGLISH_STOP_WORDS_SET to check if the given term is a stop word.
 * /*from  w ww  .j  ava  2s  . c  om*/
 * @return
 */
public static boolean isStopWord(String word) {
    if (word == null || word.isEmpty())
        return true;

    CharArraySet stopWords = (CharArraySet) StopAnalyzer.ENGLISH_STOP_WORDS_SET;
    return stopWords.contains(word.toLowerCase());
}

From source file:de.dlr.knowledgefinder.dataimport.utils.transformer.ExcludeValuesTransformer.java

License:Apache License

@Override
public Object transformRow(Map<String, Object> row, Context ctx) {

    context = ctx;//  w  w  w  . j a  v a 2 s .  c om

    for (Map<String, String> map : context.getAllEntityFields()) {
        String idField = map.get(EXCLUDE_FIELD);
        String column = map.get(DataImporter.COLUMN);
        String srcCol = map.get(SRC_COL_NAME);

        srcCol = srcCol == null ? column : srcCol;

        if (idField != null) {
            CharArraySet excludeValues = null;
            try {
                excludeValues = initializeExcludeValues(idField);
            } catch (IOException e) {
                wrapAndThrow(SEVERE, e);
            }

            Object currentRowValue = row.get(srcCol);

            if (currentRowValue == null)
                return row;

            if (currentRowValue instanceof Object[]) {

                putNotExcludedArrayValues(row, column, excludeValues, currentRowValue);

            } else {

                if (excludeValues.contains(currentRowValue)) {
                    row.put(column, null);
                } else {
                    row.put(column, currentRowValue);
                }
            }
        }
    }
    return row;
}

From source file:de.dlr.knowledgefinder.dataimport.utils.transformer.ExcludeValuesTransformer.java

License:Apache License

private void putNotExcludedArrayValues(Map<String, Object> row, String column, CharArraySet excludeValues,
        Object currentRowValue) {

    List<String> results = new ArrayList<String>();
    List<Object> values = new ArrayList<Object>();
    String[] arrayResult = null;/*from   www.  ja  v  a  2 s  . com*/
    values.addAll(Arrays.asList((Object[]) currentRowValue));

    for (Object value : values) {
        String valStr = value.toString();
        if (!excludeValues.contains(valStr.toCharArray())) {
            results.add(valStr);
        }
    }

    if (results.size() > 0) {
        arrayResult = results.toArray(new String[results.size()]);
    }

    row.put(column, arrayResult);
}