Search in sources :

Example 1 with CommentQueryResultRow

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());
}
Also used : TagDefinition(de.catma.tag.TagDefinition) Comment(de.catma.document.comment.Comment) TagQueryResultRow(de.catma.queryengine.result.TagQueryResultRow) CommentQueryResultRow(de.catma.queryengine.result.CommentQueryResultRow) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with CommentQueryResultRow

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;
}
Also used : Comment(de.catma.document.comment.Comment) CommentQueryResultRow(de.catma.queryengine.result.CommentQueryResultRow) TermExtractor(de.catma.indexer.TermExtractor) Reply(de.catma.document.comment.Reply) QueryResultRowArray(de.catma.queryengine.result.QueryResultRowArray)

Aggregations

Comment (de.catma.document.comment.Comment)2 CommentQueryResultRow (de.catma.queryengine.result.CommentQueryResultRow)2 Reply (de.catma.document.comment.Reply)1 TermExtractor (de.catma.indexer.TermExtractor)1 QueryResultRowArray (de.catma.queryengine.result.QueryResultRowArray)1 TagQueryResultRow (de.catma.queryengine.result.TagQueryResultRow)1 TagDefinition (de.catma.tag.TagDefinition)1 ExecutionException (java.util.concurrent.ExecutionException)1