use of de.catma.queryengine.result.QueryResultRow in project catma by forTEXT.
the class SimilQuery method searchTermsBySimilarity.
/**
* Searches a list of terms that a similar to the given phrase by a certain degree
*
* @param phrase the phrase to compare with
* @param similPercent the degree of similarity
* @return the list of similar terms
* @throws Exception
* @see org.catma.queryengine.Simil
*/
private QueryResult searchTermsBySimilarity() throws Exception {
QueryResultRowArray result = new QueryResultRowArray();
Simil simil = new Simil(phrase);
FreqQuery freqQuery = new FreqQuery(CompareOperator.GREATERTHAN.toString(), "0");
freqQuery.setQueryOptions(getQueryOptions());
QueryResult allTokens = freqQuery.getResult();
Set<GroupedQueryResult> allTypes = allTokens.asGroupedSet();
for (GroupedQueryResult groupedQueryResult : allTypes) {
String type = groupedQueryResult.getGroup().toString();
if (simil.getSimilarityInPercentFor(type) >= similPercent) {
for (QueryResultRow row : groupedQueryResult) {
result.add(row);
}
}
}
return result;
}
use of de.catma.queryengine.result.QueryResultRow in project catma by forTEXT.
the class TagDiffQuery method execute.
@Override
protected QueryResult execute() throws Exception {
QueryOptions queryOptions = getQueryOptions();
Project repository = queryOptions.getRepository();
Indexer indexer = queryOptions.getIndexer();
List<String> relevantUserMarkupCollIDs = queryOptions.getRelevantUserMarkupCollIDs();
if (relevantUserMarkupCollIDs.isEmpty() && !queryOptions.getRelevantSourceDocumentIDs().isEmpty()) {
relevantUserMarkupCollIDs = new ArrayList<String>();
for (String sourceDocumentId : queryOptions.getRelevantSourceDocumentIDs()) {
for (AnnotationCollectionReference umcRef : repository.getSourceDocument(sourceDocumentId).getUserMarkupCollectionRefs()) {
relevantUserMarkupCollIDs.add(umcRef.getId());
}
}
if (relevantUserMarkupCollIDs.isEmpty()) {
return new QueryResultRowArray();
}
}
QueryResult result = indexer.searchTagDiff(queryOptions.getQueryId(), relevantUserMarkupCollIDs, propertyName, tagPhrase);
for (QueryResultRow row : result) {
SourceDocument sd = repository.getSourceDocument(row.getSourceDocumentId());
TagQueryResultRow tRow = (TagQueryResultRow) row;
if (tRow.getRanges().size() > 1) {
StringBuilder builder = new StringBuilder();
String conc = "";
for (Range range : tRow.getRanges()) {
builder.append(conc);
builder.append(sd.getContent(range));
conc = "[...]";
}
row.setPhrase(builder.toString());
} else {
row.setPhrase(sd.getContent(row.getRange()));
}
}
return result;
}
use of de.catma.queryengine.result.QueryResultRow in project catma by forTEXT.
the class WildcardQuery method execute.
@Override
protected QueryResult execute() throws Exception {
QueryOptions queryOptions = getQueryOptions();
WildcardTermExtractor termExtractor = new WildcardTermExtractor(wildcardPhrase, queryOptions.getUnseparableCharacterSequences(), queryOptions.getUserDefinedSeparatingCharacters(), queryOptions.getLocale());
List<String> termList = termExtractor.getOrderedTerms();
Indexer indexer = queryOptions.getIndexer();
QueryResult result = indexer.searchWildcardPhrase(queryOptions.getQueryId(), queryOptions.getRelevantSourceDocumentIDs(), termList, queryOptions.getLimit());
Project repository = queryOptions.getRepository();
for (QueryResultRow row : result) {
SourceDocument sd = repository.getSourceDocument(row.getSourceDocumentId());
row.setPhrase(sd.getContent(row.getRange()));
}
return result;
}
use of de.catma.queryengine.result.QueryResultRow in project catma by forTEXT.
the class KwicPanel method initComponents.
private void initComponents() {
setSizeFull();
setMargin(false);
setSpacing(false);
btExpandCompress = new IconButton(expandResource);
btExpandCompress.setVisible(false);
kwicDataProvider = new ListDataProvider<>(new HashSet<>());
kwicGrid = new Grid<QueryResultRow>(kwicDataProvider);
kwicGrid.setSizeFull();
kwicGrid.addColumn(row -> kwicItemHandler.getDocumentName(row)).setCaption("Document").setWidth(200).setHidable(true);
kwicGrid.addColumn(row -> kwicItemHandler.getCollectionName(row)).setCaption("Collection").setWidth(200).setId(ColumnId.COLLECION_NAME.name()).setHidable(true).setHidden(true);
Column<QueryResultRow, ?> backwardCtxColumn = kwicGrid.addColumn(row -> kwicItemHandler.getBackwardContext(row)).setCaption("Left Context").setStyleGenerator(row -> kwicItemHandler.getBackwardContextStyle(row)).setWidth(200);
Column<QueryResultRow, ?> keywordColumn = kwicGrid.addColumn(row -> kwicItemHandler.getKeyword(row)).setCaption("Keyword").setWidth(200).setRenderer(new HtmlRenderer()).setStyleGenerator(row -> kwicItemHandler.getKeywordStyle(row)).setDescriptionGenerator(row -> kwicItemHandler.getKeywordDescription(row), ContentMode.HTML);
kwicGrid.addColumn(row -> kwicItemHandler.getForwardContext(row)).setCaption("Right Context").setStyleGenerator(row -> kwicItemHandler.getForwardContextStyle(row)).setWidth(200);
kwicGrid.addColumn(row -> row.getRange().getStartPoint()).setCaption("Start Point").setWidth(100).setId(ColumnId.START_POS.name()).setHidable(true);
kwicGrid.addColumn(row -> row.getRange().getEndPoint()).setCaption("End Point").setWidth(100).setHidable(true);
kwicGrid.addColumn(row -> kwicItemHandler.getTagPath(row)).setCaption("Tag").setHidable(true).setHidden(true).setId(ColumnId.TAG.name()).setWidth(200);
kwicGrid.addColumn(row -> kwicItemHandler.getPropertyName(row)).setCaption("Property").setHidable(true).setHidden(true).setId(ColumnId.PROPERTY_NAME.name()).setWidth(200);
kwicGrid.addColumn(row -> kwicItemHandler.getPropertyValue(row)).setCaption("Value").setHidable(true).setHidden(true).setId(ColumnId.PROPERTY_VALUE.name()).setWidth(200);
kwicGrid.sort(keywordColumn);
kwicGrid.getDefaultHeaderRow().getCell(keywordColumn).setStyleName("kwic-panel-keyword-header");
kwicGrid.getDefaultHeaderRow().getCell(backwardCtxColumn).setStyleName("kwic-panel-backwardctx-header");
kwicGridComponent = new ActionGridComponent<>(new Label("Keyword in context"), kwicGrid);
kwicGridComponent.getActionGridBar().setAddBtnVisible(false);
kwicGridComponent.getActionGridBar().addButtonRight(btExpandCompress);
kwicGridComponent.setMargin(new MarginInfo(false, false, false, true));
addComponent(kwicGridComponent);
setExpandRatio(kwicGridComponent, 1f);
btnClearSelectedRows = new IconButton(VaadinIcons.ERASER);
btnClearSelectedRows.setVisible(false);
btnClearSelectedRows.setDescription("Remove the selected rows from this list");
}
use of de.catma.queryengine.result.QueryResultRow in project catma by forTEXT.
the class KwicPanel method getFilteredQueryResult.
public QueryResultRowArray getFilteredQueryResult() {
QueryResultRowArray result = new QueryResultRowArray();
kwicDataProvider.fetch(new Query<QueryResultRow, SerializablePredicate<QueryResultRow>>()).forEach(row -> result.add(row));
return result;
}
Aggregations