nordlys.logic.el.ltr module

LTR Entity Linking Approach

Class for Learning-to-Rank entity linking approach

Author:Faegheh Hasibi
class nordlys.logic.el.ltr.LTR(query, entity, elastic, fcache, model=None, threshold=None, cmns_th=0.1)[source]

Bases: object

disambiguate(inss)[source]

Performs disambiguation

static gen_train_set(gt, query_file, train_set)[source]

Trains LTR model for entity linking.

get_candidate_inss()[source]

Detects mentions and their candidate entities (with their commoness scores) and generates instances

Returns:Instances object
get_features(ins, cand_ens=None)[source]

Generates the features set for each instance.

Parameters:
  • ins – instance object
  • cand_ens – dictionary of candidate entities {en_id: cmns, …}
Returns:

dictionary of features {ftr_name: value, …}

Links the query to the entity.

Returns:dictionary [{“mention”: xx, “entity”: yy, “score”: zz}, …]
static load_yerd(gt_file)[source]

Reads the Y-ERD collection and returns a dictionary.

Parameters:gt_file – Path to the Y-ERD collection
Returns:dictionary {(qid, query, en_id, mention) …}
rank_ens()[source]

Ranks instances according to the learned LTR model

Parameters:n – length of n-gram
Returns:dictionary {(dbp_uri, fb_id):commonness, ..}
static train(config)[source]