nordlys.logic.features.ftr_entity_similarity module¶
FTR Entity Similarity¶
Implements features capturing the similarity between entity and a query.
Author: | Faegheh Hasibi |
---|
-
class
nordlys.logic.features.ftr_entity_similarity.
FtrEntitySimilarity
(query, en_id, elastic)[source]¶ Bases:
object
-
DEBUG
= 0¶
-
context_sim
(mention, field='catchall')[source]¶ - LM score of entity to the context of query (context means query - mention)
- E.g. given the query “uss yorktown charleston” and mention “uss”,
- query context is ” yorktown charleston”
Parameters: - mention – string
- field – field name
:return context similarity score
-
lm_score
(field='catchall')[source]¶ Query length normalized LM score between entity field and query
Parameters: field – field name :return MLM score
-
mlm_score
(field_weights)[source]¶ Query length normalized MLM similarity between the entity and query
Parameters: field_weights – dictionary {field: weight, …} :return MLM score
-
nllr
(query, field_weights)[source]¶ - Computes Normalized query likelihood (NLLR):
NLLR(q,d) = sum_{t in q} P(t|q) log P(t| heta_d) - sum_{t in q} p(t|q) log P(t|C) where:
P(t|q) = n(t,q)/|q| P(t|C) = sum_{f} mu_f * P(t|C_f) P(t| heta_d) = smoothed LM/MLM score
Parameters: - query – query
- field_weights – dictionary {field: weight, …}
Returns: NLLR score
-