Example usage for org.apache.solr.common.util StrUtils splitFileNames

List of usage examples for org.apache.solr.common.util StrUtils splitFileNames

Introduction

In this page you can find the example usage for org.apache.solr.common.util StrUtils splitFileNames.

Prototype

public static List<String> splitFileNames(String fileNames) 

Source Link

Document

Splits file names separated by comma character.

Usage

From source file:com.github.le11.nls.solr.TypeAwareSynonymFilterFactory.java

License:Apache License

/**
 * Load synonyms from the solr format, "format=solr".
 *//*w  w  w .  java 2  s  . c  o  m*/
private SynonymMap loadSolrSynonyms(ResourceLoader loader, boolean dedup, Analyzer analyzer)
        throws IOException, ParseException {
    final boolean expand = getBoolean("expand", true);
    String synonyms = args.get("synonyms");
    if (synonyms == null)
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Missing required argument 'synonyms'.");

    CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder().onMalformedInput(CodingErrorAction.REPORT)
            .onUnmappableCharacter(CodingErrorAction.REPORT);

    SolrSynonymParser parser = new SolrSynonymParser(dedup, expand, analyzer);
    File synonymFile = new File(synonyms);
    if (synonymFile.exists()) {
        decoder.reset();
        parser.add(new InputStreamReader(loader.openResource(synonyms), decoder));
    } else {
        List<String> files = StrUtils.splitFileNames(synonyms);
        for (String file : files) {
            decoder.reset();
            parser.add(new InputStreamReader(loader.openResource(file), decoder));
        }
    }
    return parser.build();
}

From source file:com.github.le11.nls.solr.TypeAwareSynonymFilterFactory.java

License:Apache License

/**
 * Load synonyms from the wordnet format, "format=wordnet".
 *//*from  ww  w .j  a  va  2  s  .  c o m*/
private SynonymMap loadWordnetSynonyms(ResourceLoader loader, boolean dedup, Analyzer analyzer)
        throws IOException, ParseException {
    final boolean expand = getBoolean("expand", true);
    String synonyms = args.get("synonyms");
    if (synonyms == null)
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Missing required argument 'synonyms'.");

    CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder().onMalformedInput(CodingErrorAction.REPORT)
            .onUnmappableCharacter(CodingErrorAction.REPORT);

    WordnetSynonymParser parser = new WordnetSynonymParser(dedup, expand, analyzer);
    File synonymFile = new File(synonyms);
    if (synonymFile.exists()) {
        decoder.reset();
        parser.add(new InputStreamReader(loader.openResource(synonyms), decoder));
    } else {
        List<String> files = StrUtils.splitFileNames(synonyms);
        for (String file : files) {
            decoder.reset();
            parser.add(new InputStreamReader(loader.openResource(file), decoder));
        }
    }
    return parser.build();
}

From source file:org.vietspider.solr2.index.WordDelimiterFilterFactory.java

License:Apache License

public void inform(ResourceLoader loader) {
    String wordFiles = args.get(PROTECTED_TOKENS);
    if (wordFiles != null) {
        try {//from w  ww  .java 2 s.  com
            protectedWords = getWordSet(loader, wordFiles, false);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    String types = args.get(TYPES);
    if (types != null) {
        try {
            List<String> files = StrUtils.splitFileNames(types);
            List<String> wlist = new ArrayList<String>();
            for (String file : files) {
                List<String> lines = loader.getLines(file.trim());
                wlist.addAll(lines);
            }
            typeTable = parseTypes(wlist);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}