medcat.linking.vector_context_model
Module Contents
Classes
Used to learn embeddings for concepts and calculate similarities in new documents. |
Attributes
- medcat.linking.vector_context_model.logger
- class medcat.linking.vector_context_model.ContextModel(cdb, vocab, config)
Bases:
object
Used to learn embeddings for concepts and calculate similarities in new documents.
- Parameters:
- __init__(cdb, vocab, config)
- Parameters:
cdb (medcat.cdb.CDB) –
vocab (medcat.vocab.Vocab) –
config (medcat.config.Config) –
- Return type:
None
- get_context_tokens(entity, doc, size)
Get context tokens for an entity, this will skip anything that is marked as skip in token._.to_skip
- get_context_vectors(entity, doc, cui=None)
Given an entity and the document it will return the context representation for the given entity.
- similarity(cui, entity, doc)
Calculate the similarity between the learnt context for this CUI and the context in the given doc.
- _similarity(cui, vectors)
Calculate similarity once we have vectors and a cui.
- Parameters:
cui (str) – The CUI.
vectors (Dict) – The vectors.
- Returns:
float – The similarity.
- Return type:
float
- disambiguate(cuis, entity, name, doc)
- Parameters:
cuis (List) –
entity (spacy.tokens.Span) –
name (str) –
doc (spacy.tokens.Doc) –
- Return type:
Tuple
- train(cui, entity, doc, negative=False, names=[])
Update the context representation for this CUI, given it’s correct location (entity) in a document (doc).
- Parameters:
- Return type:
None
- train_using_negative_sampling(cui)
- Parameters:
cui (str) –
- Return type:
None