// traverse selected text assertions
MGraph queryTermMetadata = ci.getMetadata();
Iterator<Triple> textAnnotations = queryTermMetadata.filter(null,
Properties.ENHANCER_SELECTED_TEXT, null);
while (textAnnotations.hasNext()) {
Resource r = textAnnotations.next().getObject();
String selectedText = "";
if (r instanceof Literal) {
selectedText = ((Literal) r).getLexicalForm();
} else {
selectedText = r.toString();
}
tokenizedTerms.add(selectedText);
}
// get language of the query term
String language = "en";
Iterator<Triple> lanIt = queryTermMetadata.filter(null, Properties.DC_LANGUAGE, null);
if (lanIt.hasNext()) {
Resource r = lanIt.next().getObject();
if (r instanceof Literal) {
language = ((Literal) r).getLexicalForm();
} else {
language = r.toString();
}
}
/*
* If there is no stopword list for the language detected, it is highly possible that the default
* language is detected is false. As English is the most common language, it is set as default.