Search in sources :

Example 1 with OntologyTermHitEntity

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;
}
Also used : OntologyTermHitEntity(org.molgenis.ontology.sorta.bean.OntologyTermHitEntity) Entity(org.molgenis.data.Entity) OntologyTermHitEntity(org.molgenis.ontology.sorta.bean.OntologyTermHitEntity)

Example 2 with OntologyTermHitEntity

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;
}
Also used : OntologyTermHitEntity(org.molgenis.ontology.sorta.bean.OntologyTermHitEntity) Entity(org.molgenis.data.Entity) OntologyTermHitEntity(org.molgenis.ontology.sorta.bean.OntologyTermHitEntity)

Aggregations

Entity (org.molgenis.data.Entity)2 OntologyTermHitEntity (org.molgenis.ontology.sorta.bean.OntologyTermHitEntity)2