Datasets
termxtract.datasets loads standard term-extraction datasets as Teanga corpora, with the gold terms in a terms span layer. Datasets are not distributed with TermXtract: each one is downloaded from its original source (or, for HTEC, its Teanga version on Zenodo) on first use, checked against a SHA-256 checksum, and cached under ~/.cache/termxtract. Set the TERMXTRACT_DATA environment variable, or pass home=, to cache them elsewhere.
from termxtract import TermExtractor, datasets, evaluate
corpus = datasets.load("acter", split="test", language="en")
results = TermExtractor(method="cvalue", words_layer="tokens").extract(corpus)
scores = evaluate(results, corpus, top_k=1000)
Each dataset keeps its own license, given by datasets.info(name).license; please cite the publication in datasets.info(name).citation when you use it.
| Name | Dataset | Languages | Domains | License | Splits | Options |
|---|---|---|---|---|---|---|
acl-rd-tec |
ACL RD-TEC 2.0 | en | computational linguistics | CC BY-NC-SA 4.0 | annotator, labels |
|
genia |
GENIA term corpus 3.02 | en | biomedicine | GENIA Project License (annotations CC BY 3.0) | nested, labels |
|
htec |
HTEC 2.0 | hi | education | CC BY-SA 4.0 | partial_words, labels |
|
rsdo5 |
RSDO5 1.1 | sl | biomechanics, linguistics, chemistry, veterinary science | CC BY-SA 4.0 | domains, labels |
|
acter |
ACTER 1.5 | en, fr, nl | corruption, dressage, heart failure, wind energy | CC BY-NC-SA 4.0 | train, test |
language, domains, include_named_entities, labels |
ACTER
ACTER (Annotated Corpora for Term Extraction Research) is the benchmark of the TermEval 2020 shared task. Each annotated text is a document. The train split has the corruption, dressage and wind energy domains, and the test split heart failure, as in TermEval. By default only English is loaded, and named entities do not count as terms.
ACTER lists the terms of each language and domain, not their occurrences, so the terms layer marks every occurrence of a listed term in a document, nested terms included, and categories gives its label. ACTER's own sequential IOB labels, for token classification, are in the iob layer, alongside tokens, sentences and source (the file name).
ACTER, the Annotated Corpora for Term Extraction Research, version 1.5.
load_acter(path, *, split=None, language='en', domains=None, include_named_entities=False, labels=None)
Load ACTER from the archive of its GitHub repository.
Each annotated text is a document, with these layers:
text, andsource, the name of its file (such ashtfl_en_001).tokensandsentences, from ACTER's tokenised texts.terms(GOLD_LAYER): every occurrence in the document of a term in ACTER's list of tokenised annotations for the language and domain, including nested terms, within a sentence and at token boundaries, ignoring case. ACTER lists its terms per corpus, not per occurrence, so as in TermEval a term is gold wherever it occurs.categories(CATEGORY_LAYER): the label of each term, one ofTERM_LABELSorNAMED_ENTITY. A term labelled differently in different contexts has its most frequent label.iob: ACTER's sequential IOB labels, one per token. These give the longest annotation where annotations are nested, and include partly annotated tokens and interrupted terms. They followinclude_named_entitiesbut notlabels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
The ACTER archive. |
required |
split
|
Optional[str]
|
|
None
|
language
|
str
|
|
'en'
|
domains
|
Optional[Union[str, Iterable[str]]]
|
Domains to load, from |
None
|
include_named_entities
|
bool
|
Count named entities as gold terms. |
False
|
labels
|
Optional[Iterable[str]]
|
The labels of the gold terms, from
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Corpus |
Corpus
|
The documents, in order of domain and file name. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an option is unknown or no domain is left to load. |
ACL RD-TEC 2.0
The ACL RD-TEC 2.0 annotates terms in context in 300 abstracts of ACL Anthology papers (1978–2006), and classes each term as a method or technique (tech), tool, language resource (lr), named language resource (lr-prod), model, measure (measure(ment)) or other. It is downloaded from LINDAT/CLARIN.
Two annotators annotated the abstracts, and 171 were annotated by both. By default each abstract is loaded once, with the annotations of annotator 1 where there are two, since annotator 1 was the more consistent in the authors' self-agreement study; pass annotator=1 or annotator=2 for one annotator's abstracts and annotations. The documents also have the lemma, pos (Penn Treebank) and upos (Universal Dependencies) layers of the distribution's tagged files, so pos_pattern="noun_phrase" works without a tagger.
The ACL RD-TEC 2.0, abstracts of computational linguistics papers with annotated terms.
CLASSES = ('tech', 'tool', 'lr', 'lr-prod', 'model', 'measure(ment)', 'other')
module-attribute
The classes of terms:
tech: methods and techniques, such asdecision-tree approach.tool: tools and systems, such asGE NLToolset.lr: language resources, such aslexicon.lr-prod: specific, named language resources, such asThe Wall Street Journal.model: models, such astri-gram model.measure(ment): measures and measurements, such asprobabilities.other: other terms, such aswords.
PTB_TO_UPOS = {'CC': 'CCONJ', 'CD': 'NUM', 'DT': 'DET', 'EX': 'PRON', 'FW': 'X', 'IN': 'ADP', 'JJ': 'ADJ', 'JJR': 'ADJ', 'JJS': 'ADJ', 'LS': 'X', 'MD': 'AUX', 'NN': 'NOUN', 'NNS': 'NOUN', 'NNP': 'PROPN', 'NNPS': 'PROPN', 'PDT': 'DET', 'POS': 'PART', 'PRP': 'PRON', 'PRP$': 'PRON', 'RB': 'ADV', 'RBR': 'ADV', 'RBS': 'ADV', 'RP': 'ADP', 'SYM': 'SYM', 'TO': 'PART', 'UH': 'INTJ', 'VB': 'VERB', 'VBD': 'VERB', 'VBG': 'VERB', 'VBN': 'VERB', 'VBP': 'VERB', 'VBZ': 'VERB', 'WDT': 'DET', 'WP': 'PRON', 'WP$': 'PRON', 'WRB': 'ADV', '$': 'SYM', '#': 'SYM'}
module-attribute
The Universal Dependencies tag of each Penn Treebank tag. Other tags, which are all
punctuation, map to PUNCT.
load_acl_rd_tec(path, *, split=None, annotator=None, labels=None)
Load the ACL RD-TEC 2.0 from its LINDAT/CLARIN distribution.
Each annotated abstract is a document. The titles of the papers are not included, since terms are only annotated in the abstracts. One abstract, M92-1025, has no sentence markup and no tokens in the distribution, and is left out, so the corpus has at most 299 abstracts. The layers are:
text, the sentences of the abstract separated by spaces, andsource, its ACL Anthology ID (such asP99-1080).tokens,sentences,lemmaandpos, from the distribution's part-of-speech-tagged files (tagged with Stanford CoreNLP), andupos, their tags converted to Universal Dependencies withPTB_TO_UPOS, as the part-of-speech patterns of the extractors expect.terms(GOLD_LAYER): the annotated terms, which do not nest.categories(CATEGORY_LAYER): the class of each term, one ofCLASSES.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
The distribution archive. |
required |
split
|
Optional[str]
|
Not used: the dataset has no splits. |
None
|
annotator
|
Optional[int]
|
1 or 2 to load the abstracts annotated by that annotator, with their annotations. None (the default) loads every abstract once, with the annotations of annotator 1 where both annotated it, since annotator 1 was more consistent in the authors' self-agreement study. |
None
|
labels
|
Optional[Iterable[str]]
|
The classes of the gold terms, from
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Corpus |
Corpus
|
The abstracts, in order of their ACL Anthology IDs. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
GENIA
The GENIA term corpus 3.02 annotates biomedical terms in 2,000 MEDLINE abstracts on transcription factors in human blood cells, in 36 classes of the GENIA ontology such as protein_molecule and cell_type. Each title and abstract is a document. It is downloaded from NaCTeM. The annotations are licensed under CC BY 3.0 and must be attributed as "Corpus annotations (c) GENIA Project"; the abstracts are under PubMed's terms.
Terms nest deeply in GENIA (IL-2 gene expression contains IL-2 gene, which contains IL-2). By default only the outermost terms are gold terms; pass nested=True for all of them. Coordinated terms such as alpha- and beta-globin are left out. The corpus is not tokenised, so the loader splits the text at whitespace and splits punctuation off the ends of words, keeping words such as IL-2, Ca2+ and 1,25(OH)2D3 whole so that extracted terms can match the gold terms.
The GENIA term corpus 3.02: MEDLINE abstracts on transcription factors in human blood cells, with biomedical terms annotated in 36 classes.
CLASSES = ('amino_acid_monomer', 'atom', 'body_part', 'carbohydrate', 'cell_component', 'cell_line', 'cell_type', 'DNA_domain_or_region', 'DNA_family_or_group', 'DNA_molecule', 'DNA_N/A', 'DNA_substructure', 'inorganic', 'lipid', 'mono_cell', 'multi_cell', 'nucleotide', 'other_artificial_source', 'other_name', 'other_organic_compound', 'peptide', 'polynucleotide', 'protein_complex', 'protein_domain_or_region', 'protein_family_or_group', 'protein_molecule', 'protein_N/A', 'protein_subunit', 'protein_substructure', 'RNA_domain_or_region', 'RNA_family_or_group', 'RNA_molecule', 'RNA_N/A', 'RNA_substructure', 'tissue', 'virus')
module-attribute
The classes of the GENIA ontology that terms are annotated with.
load_genia(path, *, split=None, nested=False, labels=None)
Load the GENIA term corpus from its archive.
Each of the 2,000 MEDLINE abstracts is a document, with these layers:
text, the title and abstract, their sentences separated by spaces, andsource, the MEDLINE identifier (such asMEDLINE:95369245).sentences, from the corpus, andtokens. The corpus is not tokenised, so the tokens are the text split at whitespace, with brackets, quotes and punctuation split off the ends of each token unless they close a bracket inside it. Words such asIL-2,Ca2+and1,25(OH)2D3stay whole, so that extracted terms match the gold terms.terms(GOLD_LAYER): the annotated terms. By default only the outermost terms are kept: in<IL-2 gene> expression, annotated as a term with the termIL-2 geneinside it, onlyIL-2 gene expression. Coordinated terms, such asalpha- and beta-globin, are left out, since their text is not a term, but complete terms inside them are kept.categories(CATEGORY_LAYER): the class of each term, one ofCLASSES. Where the same text is annotated twice, nested in itself, it is one term with the outer class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
The corpus archive. |
required |
split
|
Optional[str]
|
Not used: the corpus has no splits. |
None
|
nested
|
bool
|
Keep the terms nested inside other terms too. |
False
|
labels
|
Optional[Iterable[str]]
|
The classes of the gold terms, from
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Corpus |
Corpus
|
The abstracts, in the order of the corpus. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a label is unknown. |
HTEC 2.0
HTEC 2.0, the Hindi Term Extraction Corpus, annotates education terms in 97 documents, segments of 65 Hindi Wikipedia articles, in seven categories such as Educationists, Learners and Researchers and Ambiguous (Banerjee, Chakravarthi & McCrae, 2025). It is downloaded from Zenodo, as a Teanga file converted from the annotation tool's files, under CC BY-SA 4.0 like the Wikipedia texts. source gives the document ID, such as 99_a; documents with the same number come from the same article.
The corpus is not tokenised, so the loader splits the text into words, keeping Devanagari vowel signs and viramas inside them, and into sentences at line breaks and after ।, ?, ! and .. The annotations include nested and overlapping terms, all kept. Some start inside a word, such as शोध in संशोधित, and are left out unless partial_words=True; those that end inside a word, mostly stems of inflected words such as कक्षा in कक्षाओं, are kept.
HTEC 2.0, the Hindi Term Extraction Corpus: Hindi Wikipedia articles on education, with terms annotated in seven categories.
CATEGORIES = ('Ambiguous', 'Educational Institutions, Governing bodies, Think Tanks and Research Institutes', 'Degrees, Disciplines and different stages of education', 'Educationists, Learners and Researchers', 'Education Related Policy and Regulatory Frameworks', 'Mode of Dissemination', 'Education Technology and Equipment')
module-attribute
The categories of the terms, as named in Table 6.1 of Banerjee (2025).
load_htec(path, *, split=None, partial_words=False, labels=None)
Load HTEC 2.0 from its Teanga file.
Each of the 97 documents is a segment of one of 65 Hindi Wikipedia articles on education, with these layers:
text, andsource, the document ID (such as99_a). Documents with the same number come from the same article.tokensandsentences. The corpus is not tokenised, so the tokens are runs of letters, digits and Devanagari signs, with every other character but a space a token of its own, and sentences end at line breaks and after।,॥,?,!and..terms(GOLD_LAYER): the annotated terms, including nested and overlapping ones. Some annotations start inside a word, such asशोधinसंशोधित; by default they are left out. Annotations that end inside a word, such asकक्षाinकक्षाओं, are mostly the stems of inflected words, and are kept.categories(CATEGORY_LAYER): the category of each term, one ofCATEGORIES.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
The Teanga YAML file of the corpus. |
required |
split
|
Optional[str]
|
Not used: the corpus has no splits. |
None
|
partial_words
|
bool
|
Keep the annotations that start inside a word. |
False
|
labels
|
Optional[Iterable[str]]
|
The categories of the gold terms, from
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Corpus |
Corpus
|
The documents, in order of document ID. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a label is unknown. |
RSDO5 1.1
RSDO5 annotates every term in 12 Slovenian texts, three per domain: biomechanics (bim), linguistics (jez), chemistry (kem) and veterinary science (vet). Each domain has a doctoral thesis or a monograph, a university textbook and one or two journal articles. It has about 310,000 tokens and 37,985 annotated terms, which do not nest. Each text is a document. The corpus is downloaded from CLARIN.SI in its vertical format, under CC BY-SA 4.0.
Each term is marked in-domain, if it belongs to the domain of the text (24,282 of them), or out-domain, if it belongs to another field, such as a statistics term in a chemistry text. Both count by default; pass labels="in-domain" for the domain's own terms. Pass domains to load some of the domains, for example to train on three and test on the fourth, as in the cross-domain experiments of Tran et al. (2024).
The corpus comes with its Universal Dependencies annotation, so the documents have tokens, sentences, lemma, upos and msd (MULTEXT-East) layers, and lemma_layer="lemma" and pos_pattern="noun_phrase" work without a tagger.
RSDO5 1.1: twelve Slovenian texts in four domains, with every term annotated and marked as in-domain or out-domain.
DOMAINS = ('bim', 'jez', 'kem', 'vet')
module-attribute
The domains of RSDO5, as in its file names: biomechanics (biomehanika), linguistics (jezikoslovje), chemistry (kemija) and veterinary science (veterina).
LABELS = ('in-domain', 'out-domain')
module-attribute
The labels of the terms: of the domain of the text, or of another field.
load_rsdo5(path, *, split=None, domains=None, labels=None)
Load RSDO5 from the archive of its vertical files.
Each of the 12 texts (a doctoral thesis, a textbook and one or two journal articles per domain) is a document, with these layers:
text, rebuilt from the tokens, with a line break between paragraphs, andsource, the ID of the text (such asrsdo5bimdis).tokensandsentences, from the corpus's Universal Dependencies annotation.lemma,upos(Universal Dependencies) andmsd(MULTEXT-East) layers, based ontokens.terms(GOLD_LAYER): the annotated terms. They do not nest.categories(CATEGORY_LAYER): whether each term isin-domainorout-domain, one ofLABELS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
The archive of the vertical files. |
required |
split
|
Optional[str]
|
Not used: the corpus has no splits. To train on some
domains and test on another, load each with |
None
|
domains
|
Optional[Union[str, Iterable[str]]]
|
Domains to load, from
|
None
|
labels
|
Optional[Iterable[str]]
|
The labels of the gold terms, from |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Corpus |
Corpus
|
The texts, in order of ID. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a domain or label is unknown. |
Adding a dataset
A dataset is a DatasetInfo passed to register. Its loader receives the paths of the downloaded resources, a split keyword argument and the dataset's options as keyword-only arguments, and returns a Teanga corpus with a terms span layer, plus a categories layer if the dataset classifies its terms.
GOLD_LAYER = 'terms'
module-attribute
The span layer that holds the gold terms of a loaded dataset.
CATEGORY_LAYER = 'categories'
module-attribute
The sequence layer, based on GOLD_LAYER, that holds the class of each gold term,
for datasets that classify their terms.
SOURCE_LAYER = 'source'
module-attribute
The characters layer holding the name of the file or record each document comes
from, such as htfl_en_001.
SENTENCES_LAYER = 'sentences'
module-attribute
The span layer of the sentences of each document.
DatasetInfo(name, description, languages, domains, license, citation, homepage, resources, loader, splits=())
dataclass
A dataset that load can load.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name passed to |
description |
str
|
A one-line description. |
languages |
Tuple[str, ...]
|
ISO 639 codes of the languages of the texts. |
domains |
Tuple[str, ...]
|
The domains of the texts. |
license |
str
|
The license of the dataset. |
citation |
str
|
The publication to cite when using the dataset. |
homepage |
str
|
Where the dataset is described. |
resources |
Tuple[Resource, ...]
|
The files to download. |
loader |
Callable[..., Corpus]
|
A function that takes the paths of the
downloaded resources as positional arguments, in order, then a |
splits |
Tuple[str, ...]
|
The values |
options
property
The options of the dataset: the keyword-only arguments of loader, besides
split.
Resource(url, sha256, filename)
dataclass
A file that a dataset downloads.
Attributes:
| Name | Type | Description |
|---|---|---|
url |
str
|
Where to download the file from, pinned to a fixed version. |
sha256 |
str
|
The SHA-256 checksum of the file, in hexadecimal. |
filename |
str
|
The name of the file in the dataset's cache directory. |
load(name, split=None, home=None, download_if_missing=True, **options)
Load a dataset as a Teanga corpus, downloading it on first use.
The gold terms are in the terms span layer (GOLD_LAYER), so the corpus can be
passed both to an extractor and, as the gold standard, to termxtract.evaluate.
Datasets that classify their terms also have a categories layer
(CATEGORY_LAYER).
The datasets are not distributed with TermXtract. They are downloaded from their
original sources, under their own licenses, which info(name).license gives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the dataset; see |
required |
split
|
Optional[str]
|
The part of the dataset to load, one of
|
None
|
home
|
Optional[Union[str, PathLike]]
|
The cache directory, as for |
None
|
download_if_missing
|
bool
|
Download the dataset if it is not cached. If False,
a missing dataset raises |
True
|
**options
|
Any
|
Options of the dataset, listed in |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Corpus |
Corpus
|
The dataset. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dataset, split or an option is unknown. |
FileNotFoundError
|
If the dataset is not cached and |
download(name, home=None, force=False)
Download the files of a dataset, unless they are already cached.
Each file is checked against its SHA-256 checksum when it is downloaded, and is
stored as <data home>/<dataset name>/<filename>.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the dataset. |
required |
home
|
Optional[Union[str, PathLike]]
|
The cache directory, as for |
None
|
force
|
bool
|
Download the files again even if they are cached. |
False
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
List[Path]: The paths of the files, in the order of |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is no dataset with this name, or a downloaded file does not match its checksum. The file is then not kept. |
list_datasets()
List the datasets that load can load.
Returns:
| Type | Description |
|---|---|
list[DatasetInfo]
|
List[DatasetInfo]: The datasets, sorted by name. |
info(name)
Describe a dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the dataset. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
DatasetInfo |
DatasetInfo
|
The dataset. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is no dataset with this name. |
gold_terms(corpus, layer=GOLD_LAYER, by_document=False, lemma_layer=None)
Get the gold terms of a loaded dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
corpus
|
Corpus
|
A corpus from |
required |
layer
|
str
|
The span layer of gold terms. |
GOLD_LAYER
|
by_document
|
bool
|
Return the terms of each document instead of those of the whole corpus. |
False
|
lemma_layer
|
Optional[str]
|
A sequence layer holding the lemma of each word, as
for the |
None
|
Returns:
| Type | Description |
|---|---|
set[str] | dict[str, set[str]]
|
Union[Set[str], Dict[str, Set[str]]]: The distinct gold terms, lowercased and |
set[str] | dict[str, set[str]]
|
with whitespace collapsed, or a dictionary from document IDs to them. |
data_home(path=None)
Get the directory where datasets are cached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Optional[Union[str, PathLike]]
|
A directory to use instead of the default. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
|
Path
|
set, otherwise |
|
Path
|
|
register(info)
Make a dataset available to load.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
DatasetInfo
|
The dataset. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
DatasetInfo |
DatasetInfo
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a dataset with the same name is already registered. |