use of org.apache.jena.query.text.TextIndexException in project jena by apache.
the class StandardAnalyzerAssembler method toList.
private List<String> toList(Resource list) {
List<String> result = new ArrayList<>();
Resource current = list;
while (current != null && !current.equals(RDF.nil)) {
Statement stmt = current.getProperty(RDF.first);
if (stmt == null) {
throw new TextIndexException("stop word list not well formed");
}
RDFNode node = stmt.getObject();
if (!node.isLiteral()) {
throw new TextIndexException("stop word is not a literal : " + node);
}
result.add(((Literal) node).getLexicalForm());
stmt = current.getProperty(RDF.rest);
if (stmt == null) {
throw new TextIndexException("stop word list not terminated by rdf:nil");
}
node = stmt.getObject();
if (!node.isResource()) {
throw new TextIndexException("stop word list node is not a resource : " + node);
}
current = (Resource) node;
}
return result;
}
use of org.apache.jena.query.text.TextIndexException in project jena by apache.
the class StandardAnalyzerAssembler method analyzerWithStopWords.
private Analyzer analyzerWithStopWords(Resource root) {
RDFNode node = root.getProperty(TextVocab.pStopWords).getObject();
if (!node.isResource()) {
throw new TextIndexException("text:stopWords property takes a list as a value : " + node);
}
CharArraySet stopWords = toCharArraySet((Resource) node);
return new StandardAnalyzer(stopWords);
}
Aggregations