article package
Submodules
Article implementation.
- class core_utils.ctlr.article.article.Article(url, article_id)
Bases:
objectArticle class implementation.
- __init__(url, article_id)
Initialize an instance of Article.
- get_conllu_info()
Get the sentences from ConlluArticle.
- Returns:
Sentences from ConlluArticle
- Return type:
- get_conllu_text(include_morphological_tags)
Get the text in the CONLL-U format.
- get_file_path(kind)
Get a proper filepath for an Article instance.
- Parameters:
kind (ArtifactType) – A variant of a file
- Returns:
Path to Article instance
- Return type:
- get_meta_file_path()
Get path for requested article’s meta info.
- Returns:
Path to requested article’s meta info
- Return type:
- get_raw_text_path()
Get path for requested raw article.
- Returns:
Path to requested raw article
- Return type:
- set_conllu_info(info)
Set the conllu_sentences_attribute.
- Parameters:
info (str) – CONLL-U sentences
- Return type:
None
- class core_utils.ctlr.article.article.ArtifactType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
EnumTypes of artifacts that can be created by text processing pipelines.
- CLEANED = 'cleaned'
- UDPIPE_CONLLU = 'udpipe'
- core_utils.ctlr.article.article.date_from_meta(date_txt)
Convert text date to datetime object.
- Parameters:
date_txt (str) – Date in text format
- Returns:
Datetime object
- Return type:
- core_utils.ctlr.article.article.get_article_id_from_filepath(path)
Extract the article id from its path.
- Parameters:
path (pathlib.Path) – Path to article
- Returns:
Article id
- Return type:
- core_utils.ctlr.article.article.split_by_sentence(text)
Splits the given text by sentence separators.
I/O operations for Article.
- core_utils.ctlr.article.io.from_meta(path, article=None)
Load meta.json file into the Article abstraction.
- Parameters:
path (pathlib.Path | str) – Path to meta info
article (Article | None) – Article instance. Defaults to None.
- Returns:
Article instance
- Return type:
- core_utils.ctlr.article.io.from_raw(path, article=None)
Load raw text and create an Article with it.
- Parameters:
path (pathlib.Path | str) – Path to article raw text
article (Article | None) – Article instance. Defaults to None.
- Returns:
Article instance
- Return type:
- core_utils.ctlr.article.io.to_cleaned(article)
Save cleaned text.
- Parameters:
article (Article) – Article instance
- Return type:
None