Flair: Problem loading corpus

Created on 8 Jan 2019  路  3Comments  路  Source: flairNLP/flair

Hello guys,

I am following your tutorial about hyperparameters optimization, but there seems to be a problem when loading the NLPTask.AG_NEWS corpus:

from flair.data_fetcher import NLPTaskDataFetcher, NLPTask
corpus: TaggedCorpus = NLPTaskDataFetcher.load_corpus(NLPTask.AG_NEWS)

The code from above returns the following error:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-17-b457eea87ed8> in <module>
----> 1 corpus: TaggedCorpus = NLPTaskDataFetcher.load_corpus(NLPTask.AG_NEWS)

/usr/local/lib/python3.6/dist-packages/flair/data_fetcher.py in load_corpus(task, base_path)
    190         # for text classifiers, we use our own special format
    191         if task == NLPTask.IMDB.value or task == NLPTask.AG_NEWS.value:
--> 192             return NLPTaskDataFetcher.load_classification_corpus(data_folder)
    193
    194     @staticmethod

/usr/local/lib/python3.6/dist-packages/flair/data_fetcher.py in load_classification_corpus(data_folder, train_file, test_file, dev_file)
    345         # automatically identify train / test / dev files
    346         if train_file is None:
--> 347             for file in data_folder.iterdir():
    348                 file_name = file.name
    349                 if 'train' in file_name:

/usr/lib/python3.6/pathlib.py in iterdir(self)
   1079         if self._closed:
   1080             self._raise_closed()
-> 1081         for name in self._accessor.listdir(self):
   1082             if name in {'.', '..'}:
   1083                 # Yielding a path object for these makes little sense

/usr/lib/python3.6/pathlib.py in wrapped(pathobj, *args)
    385         @functools.wraps(strfunc)
    386         def wrapped(pathobj, *args):
--> 387             return strfunc(str(pathobj), *args)
    388         return staticmethod(wrapped)
    389

FileNotFoundError: [Errno 2] No such file or directory: '/home/<username>/.flair/datasets/ag_news'

Can I have some help to solve this? Or, if there is another way to try the hyperparameter optimization from the tutorial, please let me know.
Thanks!

bug

Most helpful comment

The AGNews dataset is not included in Flair by default. You first need to download the dataset here, convert it to the FastText format and then point the NLPTaskDataFetcher to the source path. Also take a look at
tutorial 6.

We will update the tutorial accordingly.

It looks like this is the case for tutorial 7 as well? I'm getting a 'FileNotFoundError: [Errno 2] No such file or directory: '/root/.flair/datasets/conll_03'' error

All 3 comments

The AGNews dataset is not included in Flair by default. You first need to download the dataset here, convert it to the FastText format and then point the NLPTaskDataFetcher to the source path. Also take a look at
tutorial 6.

We will update the tutorial accordingly.

Got it. Thanks for pointing this out.

The AGNews dataset is not included in Flair by default. You first need to download the dataset here, convert it to the FastText format and then point the NLPTaskDataFetcher to the source path. Also take a look at
tutorial 6.

We will update the tutorial accordingly.

It looks like this is the case for tutorial 7 as well? I'm getting a 'FileNotFoundError: [Errno 2] No such file or directory: '/root/.flair/datasets/conll_03'' error

Was this page helpful?
0 / 5 - 0 ratings