<jupyter_start><jupyter_text>Flair<jupyter_code>from google.colab import drive
drive.mount('/content/gdrive')
import os
os.chdir( "/content/gdrive/MyDrive/flair" ) 
pip install flair
from flair.data import Corpus
from flair.datasets import WIKINER_ENGLISH<jupyter_output><empty_output><jupyter_text>Next, we create __wikiner_corpus__, an instance of the class __Corpus__.*   WikiNwr is a NER dataset automatically generated from WikipediaRead [here](https://github.com/flairNLP/flair/blob/master/resources/docs/TUTORIAL_6_CORPUS.md) the documentation of __Corpus__.__Question 1__: explain, what the __WIKINER__ corpus is.Then, we create __tag_dictionary__ which is an __BILUO__-__NER__-encoding.<jupyter_code># 1. get the corpus
wikiner_corpus: Corpus = WIKINER_ENGLISH().downsample(0.1)
print(wikiner_corpus)
# 3. make the tag dictionary from the corpus
tag_dictionary = Corpus.make_tag_dictionary( wikiner_corpus, tag_type='ner')
print(tag_dictionary.idx2item)
print(wikiner_corpus.train[73])
print(wikiner_corpus.train[73].to_tagged_string())<jupyter_output>Sentence: "His mother , Maia , had been secretly impregnated by Zeus ."   [− Tokens: 12  − Token-Labels: "His <PRP$> mother <NN> , <,> Maia <NNP/S-PER> , <,> had <VBD> been <VBN> secretly <RB> impregnated <VBN> by <IN> Zeus <NNP/S-PER> . <.>"]
His <PRP$> mother <NN> , <,> Maia <NNP/S-PER> , <,> had <VBD> been <VBN> secretly <RB> impregnated <VBN> by <IN> Zeus <NNP/S-PER> . <.><jupyter_text>Ok, above, we loaded a corpus, a collection of texts, and with this collection the annotation of these texts.Next, we load the data, we prepared using Spacy.<jupyter_code>from flair.data_fetcher import NLPTaskDataFetcher

downsample = 1.0 # 1.0 is full data, try a much smaller number like 0.01 to test run the code
data_folder = os.getcwd()
columns = {0: 'text', 1: 'ner'}

# 1. get the corpus
corpus: Corpus = NLPTaskDataFetcher.load_column_corpus(data_folder, columns,
                                                             train_file='training_data.csv',
                                                             test_file='test_data.csv',
                                                           dev_file=None).downsample(downsample)
print(corpus)

# 3. make the tag dictionary from the corpus
tag_dictionary = corpus.make_tag_dictionary(tag_type='ner')
print(tag_dictionary.idx2item)<jupyter_output>2021-06-02 07:11:44,479 Reading data from /content/gdrive/My Drive/flair
2021-06-02 07:11:44,480 Train: /content/gdrive/My Drive/flair/training_data.csv
2021-06-02 07:11:44,483 Dev: None
2021-06-02 07:11:44,486 Test: /content/gdrive/My Drive/flair/test_data.csv<jupyter_text>__Question 2__: what is the difference between __tag_dictionary__ created in the cell above, and __tag_dictionary__ created before that.Next, we take the first sentence from the test data, and annotate this sentence using __to_tagged_string__.<jupyter_code>for sent in corpus.test:
  print(sent.to_tagged_string())
  break<jupyter_output><NAME> Manager Mumbai , Maharashtra - Email me on Indeed : indeed.com/r/Harinath-Rudra/7c4ee202549ec8f0 <U-Email>
StarcoderdataJupyterStructuredCleanDedup