use of org.molgenis.ontology.sorta.bean.OntologyTermHitEntity in project molgenis by molgenis.
the class SortaServiceImpl method addLexicalScoreToMatchedEntity.
Entity addLexicalScoreToMatchedEntity(Entity inputEntity, Entity ontologyTerm, // TODO Change 'Entity ontologyTerm' to 'OntologyTerm ontologyTerm'
String ontologyIri) {
double maxNgramScore = 0;
double maxNgramIDFScore = 0;
for (String inputAttrName : inputEntity.getAttributeNames()) {
String queryString = inputEntity.getString(inputAttrName);
if (StringUtils.isNotEmpty(queryString) && isAttrNameValidForLexicalMatch(inputAttrName)) {
Entity topMatchedSynonymEntity = findSynonymWithHighestNgramScore(ontologyIri, queryString, ontologyTerm);
if (maxNgramScore < topMatchedSynonymEntity.getDouble(SCORE)) {
maxNgramScore = topMatchedSynonymEntity.getDouble(SCORE);
}
if (maxNgramIDFScore < topMatchedSynonymEntity.getDouble(COMBINED_SCORE)) {
maxNgramIDFScore = topMatchedSynonymEntity.getDouble(COMBINED_SCORE);
}
}
}
OntologyTermHitEntity mapEntity = new OntologyTermHitEntity(ontologyTerm, ontologyTermHitMetaData);
mapEntity.set(SCORE, maxNgramScore);
mapEntity.set(COMBINED_SCORE, maxNgramIDFScore);
return mapEntity;
}
use of org.molgenis.ontology.sorta.bean.OntologyTermHitEntity in project molgenis by molgenis.
the class SortaServiceImpl method calculateNGromOTAnnotations.
/**
* A helper function to check if the ontology term (OT) contains the ontology annotations provided in input. If the
* OT has the same annotation, the OT will be considered as a good match and the similarity scores 100 are allocated
* to the OT
*/
private Entity calculateNGromOTAnnotations(Entity inputEntity, Entity ontologyTermEntity) {
OntologyTermHitEntity mapEntity = new OntologyTermHitEntity(ontologyTermEntity, ontologyTermHitMetaData);
for (Entity annotationEntity : ontologyTermEntity.getEntities(OntologyTermMetaData.ONTOLOGY_TERM_DYNAMIC_ANNOTATION)) {
String annotationName = annotationEntity.getString(OntologyTermDynamicAnnotationMetaData.NAME);
String annotationValue = annotationEntity.getString(OntologyTermDynamicAnnotationMetaData.VALUE);
for (String attributeName : inputEntity.getAttributeNames()) {
if (StringUtils.isNotEmpty(inputEntity.getString(attributeName)) && StringUtils.equalsIgnoreCase(attributeName, annotationName) && StringUtils.equalsIgnoreCase(inputEntity.getString(attributeName), annotationValue)) {
mapEntity.set(SCORE, 100d);
mapEntity.set(COMBINED_SCORE, 100d);
return mapEntity;
}
}
}
return mapEntity;
}
Aggregations