use of de.catma.indexer.TermExtractor in project catma by forTEXT.
the class TPGraphProjectIndexer method searchCommentPhrase.
@Override
public QueryResult searchCommentPhrase(QueryId queryId, List<String> documentIdList, List<String> termList, int limit, List<String> unseparableCharacterSequences, List<Character> userDefinedSeparatingCharacters, Locale locale) throws Exception {
List<Comment> comments = commentProvider.getComments(documentIdList);
QueryResultRowArray result = new QueryResultRowArray();
for (Comment comment : comments) {
if (termList.size() == 1 && termList.get(0).equals("%")) {
result.add(new CommentQueryResultRow(queryId, comment));
} else {
TermExtractor termExtractor = new TermExtractor(comment.getBody(), unseparableCharacterSequences, userDefinedSeparatingCharacters, locale);
List<String> commentTerms = termExtractor.getTermsInOrder();
if (matches(commentTerms, termList)) {
result.add(new CommentQueryResultRow(queryId, comment));
} else {
for (Reply reply : comment.getReplies()) {
TermExtractor replyTermExtractor = new TermExtractor(reply.getBody(), unseparableCharacterSequences, userDefinedSeparatingCharacters, locale);
List<String> replyTerms = replyTermExtractor.getTermsInOrder();
if (matches(replyTerms, termList)) {
result.add(new CommentQueryResultRow(queryId, comment));
break;
}
}
}
}
}
return result;
}
Aggregations