Search in sources :

Example 6 with TermExtractor

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;
}
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

TermExtractor (de.catma.indexer.TermExtractor)6 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 EventBus (com.google.common.eventbus.EventBus)3 BackgroundService (de.catma.backgroundservice.BackgroundService)3 ContentInfoSet (de.catma.document.source.ContentInfoSet)3 IndexInfoSet (de.catma.document.source.IndexInfoSet)3 SourceDocumentInfo (de.catma.document.source.SourceDocumentInfo)3 TechInfoSet (de.catma.document.source.TechInfoSet)3 GitLabServerManagerTest (de.catma.repository.git.managers.GitLabServerManagerTest)3 JGitRepoManager (de.catma.repository.git.managers.JGitRepoManager)3 IDGenerator (de.catma.util.IDGenerator)3 Test (org.junit.jupiter.api.Test)3 ILocalGitRepositoryManager (de.catma.repository.git.interfaces.ILocalGitRepositoryManager)2 UsernamePasswordCredentialsProvider (org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider)2 Comment (de.catma.document.comment.Comment)1 Reply (de.catma.document.comment.Reply)1 SourceDocument (de.catma.document.source.SourceDocument)1 StandardContentHandler (de.catma.document.source.contenthandler.StandardContentHandler)1 DocumentChangeEvent (de.catma.project.event.DocumentChangeEvent)1