use of de.catma.queryengine.result.CommentQueryResultRow in project catma by forTEXT.
the class KwicItemHandler method getKeywordDescription.
public String getKeywordDescription(QueryResultRow row) {
if (row instanceof TagQueryResultRow) {
TagQueryResultRow tRow = (TagQueryResultRow) row;
TagDefinition tagDefinition = project.getTagManager().getTagLibrary().getTagDefinition(tRow.getTagDefinitionId());
try {
return AnnotatedTextProvider.buildAnnotatedKeywordInContext(new ArrayList<>(tRow.getRanges()), kwicProviderCache.get(tRow.getSourceDocumentId()), tagDefinition, tRow.getTagDefinitionPath());
} catch (ExecutionException e) {
logger.log(Level.SEVERE, "error retrieving keyword description for " + row, e);
}
}
if (row instanceof CommentQueryResultRow) {
CommentQueryResultRow cRow = (CommentQueryResultRow) row;
Comment comment = cRow.getComment();
return AnnotatedTextProvider.buildCommentedKeyword(row.getPhrase(), comment);
}
return Cleaner.clean(row.getPhrase());
}
use of de.catma.queryengine.result.CommentQueryResultRow 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