Skip to content

Commit

Permalink
Release 2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dwerning committed Mar 14, 2024
1 parent e8670c2 commit 5b8e399
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/main/java/tla/backend/es/model/LemmaEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public class LemmaEntity extends TLAEntity {
@Field(type = FieldType.Object)
@JsonAlias({"time_span"})
private AttestedTimeSpan timeSpan;

@Field(type = FieldType.Keyword)
private Integer attestedSentencesCount;

@Singular
@Field(type = FieldType.Object)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void setContext(Context context) {
if (textId != null) {
log.info("sentence query: receive {} textIDs", textId);
textQuery.must(QueryBuilders.termQuery("context.textId", textId)); // Set text ID of which sentences should be retrieved
textQuery.must(QueryBuilders.regexpQuery("id", "[^\\-]*|.*\\-00")); // Sort out all sentence reading variants except for "-00"
textQuery.must(QueryBuilders.regexpQuery("id", "[^\\-]*|.*\\-0")); // Sort out all sentence reading variants except for "-0"
this.filter(textQuery);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tla/backend/service/EntityService.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public T retrieve(String id) {
public SingleDocumentWrapper<? extends AbstractDto> getDetails(String id) {
T document = this.retrieve(id);
if (document == null) {
document = this.retrieve(id.concat("-00")); // try again as an instance of a sentence variant
document = this.retrieve(id.concat("-0")); // try again as an instance of a sentence variant
}
final SingleDocumentWrapper<?> container;
if (document != null) {
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/tla/backend/service/LemmaService.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,32 @@ public SingleDocumentWrapper<? extends AbstractDto> getDetails(String id) {
if (lemma == null) {
return null;
}
SingleDocumentWrapper<?> wrapper = super.getDetails(id);
((LemmaDto) wrapper.getDoc()).setAttestations(
this.computeAttestedTimespans((LemmaDto) wrapper.getDoc())
);
SingleDocumentWrapper<?> wrapper = super.getDetails(id);
((LemmaDto) wrapper.getDoc()).setAttestations(
this.computeAttestedTimespans((LemmaDto) wrapper.getDoc())
);
return wrapper;
}

/**
* count sentences and texts containing the specified lemma.
*/
public List<AttestedTimespan> computeAttestedTimespans(LemmaDto dto) {
public List<AttestedTimespan> computeAttestedTimespans(LemmaDto dto) {
ESQueryResult<?> sentenceSearchResult = searchService.register(
new SentencesContainingLemmaOccurrenceQueryBuilder(dto.getId())
).run(SearchService.UNPAGED);
Period attestedPeriod = dto.getTimeSpan();
AttestationStats counts = AttestationStats.builder().count(
sentenceSearchResult.getAggregation(SentenceSearchQueryBuilder.AGG_ID_TEXT_IDS).size()
).texts(
sentenceSearchResult.getAggregation(SentenceSearchQueryBuilder.AGG_ID_TEXT_IDS).size()
AttestationStats counts = AttestationStats.builder().count(0
//sentenceSearchResult.getAggregation(SentenceSearchQueryBuilder.AGG_ID_TEXT_IDS).size()
).texts(0
//sentenceSearchResult.getAggregation(SentenceSearchQueryBuilder.AGG_ID_TEXT_IDS).size()
).sentences(
sentenceSearchResult.getHitCount()
).build();
return List.of(
AttestedTimespan.builder().period(attestedPeriod).attestations(counts).build()
);
}
}

public Map<String, Long> getMostFrequent(int limit) {
SearchResponse response = this.searchService.query(SentenceEntity.class, matchAllQuery(),
Expand Down

0 comments on commit 5b8e399

Please sign in to comment.