.models#

.identification.event#

class tieval.models.identification.event.EventIdentificationBaseline(path: str = './models')#

Bases: BaseTrainableModel

fit(documents: Iterable[Document], dev_documents: Iterable[Document] | None = None, dropout: float = 0, from_scratch: bool = False) None#

Tran the model.

Parameters#

documentsIterable[Document]

The set of documents to train on.

from_scratchbool

If False (the default value) it will fine-tune the model. If set to True it will train from scratch.

dropout : float dev_documents : Iterable[Document]

save()#

Store model in disk.

.identification.timex#

class tieval.models.identification.timex.HeidelTime(language='english', document_type='news')#

Bases: BaseModel

The HeidelTime model. This is a wrapper class of the py_heideltime implementation. Follow the installation steps provided in the py_heideltime repository in order for it ot work properly.

Parameters:
  • language (str) – {“English”, “Portuguese”, “Spanish”, “Germany”, “Dutch”, “Italian”, “French”} Language of the text that will be processed.

  • document_type (str) – {“News”, “Narrative”, “Colloquial”, “Scientific”} The type of document that will be processed.

predict(texts: List[str], dcts: List[str] | None = None)#

Make predictions on strings.

class tieval.models.identification.timex.TimexIdentificationBaseline(path: str = './models')#

Bases: BaseTrainableModel

fit(documents: Iterable[Document], dev_documents: Iterable[Document] | None = None, dropout: float = 0, from_scratch: bool = False) None#

Tran the model.

save()#

Store model in disk.

.classification.temporal_relation#

class tieval.models.classification.temporal_relation.cogcomp2.CogCompTime2(model_path: str = './models', resources_path: str = './resources')#

Bases: BaseTrainableModel

predict(documents: Iterable[Document]) Dict[str, List[TLink]]#

Classify the temporal relations on a set of documents.

Parameters:

documents (Iterable[Document]) – A set of documents with TLinks to be classified.

Returns:

A dictionary with the list of TLinks (with the predicted relations) for each document.

Return type:

Dict[str, List[TLink]]

class tieval.models.classification.temporal_relation.cogcomp2.CommonSenseEncoder(vocab_size: int, emb_size: int, hidden_size: int)#

Bases: Module

Network to train siamese embeddings.

forward(x)#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class tieval.models.classification.temporal_relation.cogcomp2.TemporalRelationClassifier(elmo, common_sense_encoder, granularity, common_sense_emb_dim, embedding_dim, lstm_hidden_dim, nn_hidden_dim, output_dim)#

Bases: Module

forward(entities_idxs: List[int], lemma_ids: List[int], context_tokens: List[str])#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.