flair.datasets.sequence_labeling.MultiFileJsonlCorpus#
- class flair.datasets.sequence_labeling.MultiFileJsonlCorpus(train_files=None, test_files=None, dev_files=None, encoding='utf-8', text_column_name='data', label_column_name='label', metadata_column_name='metadata', label_type='ner', use_tokenizer=True, **corpusargs)View on GitHub#
Bases:
CorpusThis class represents a generic Jsonl corpus with multiple train, dev, and test files.
- __init__(train_files=None, test_files=None, dev_files=None, encoding='utf-8', text_column_name='data', label_column_name='label', metadata_column_name='metadata', label_type='ner', use_tokenizer=True, **corpusargs)View on GitHub#
Instantiates a MuliFileJsonlCorpus as, e.g., created with doccanos JSONL export.
Note that at least one of train_files, test_files, and dev_files must contain one path. Otherwise, the initialization will fail.
- Parameters:
corpusargs – Additional arguments for Corpus initialization
train_files – the name of the train files
test_files – the name of the test files
dev_files – the name of the dev files, if empty, dev data is sampled from train
encoding (
str) – file encoding (default “utf-8”)text_column_name (
str) – Name of the text column inside the jsonl files.label_column_name (
str) – Name of the label column inside the jsonl files.metadata_column_name (
str) – Name of the metadata column inside the jsonl files.label_type (
str) – he type of label to predict (default “ner”)use_tokenizer (
Union[bool,Tokenizer]) – Specify a custom tokenizer to split the text into tokens.
- Raises:
RuntimeError – If no paths are given
Methods
__init__([train_files, test_files, ...])Instantiates a MuliFileJsonlCorpus as, e.g., created with doccanos JSONL export.
add_label_noise(label_type, labels[, ...])Generates uniform label noise distribution in the chosen dataset split.
downsample([percentage, downsample_train, ...])Randomly downsample the corpus to the given percentage (by removing data points).
filter_empty_sentences()A method that filters all sentences consisting of 0 tokens.
filter_long_sentences(max_charlength)A method that filters all sentences for which the plain text is longer than a specified number of characters.
get_all_sentences()Returns all sentences (spanning all three splits) in the
Corpus.get_label_distribution()Counts occurrences of each label in the corpus and returns them as a dictionary object.
make_label_dictionary(label_type[, ...])Creates a dictionary of all labels assigned to the sentences in the corpus.
make_tag_dictionary(tag_type)Create a tag dictionary of a given label type.
make_vocab_dictionary([max_tokens, min_freq])Creates a
Dictionaryof all tokens contained in the corpus.obtain_statistics([label_type, pretty_print])Print statistics about the corpus, including the length of the sentences and the labels in the corpus.
Attributes
devThe dev split as a
torch.utils.data.Datasetobject.testThe test split as a
torch.utils.data.Datasetobject.trainThe training split as a
torch.utils.data.Datasetobject.