sinatools.arabiner.bin.infer

sinatools.arabiner.bin.infer.ner(text, batch_size=32)

This method takes a text as input, and a batch size, then performs named entity recognition (NER) on the input text and returns a list of tagged mentions.

Parameters
  • text (str) – The input text to perform NER on.

  • batch_size (int, optional) – Batch size for inference. Default is 32.

Returns

A list of lists containing token and label pairs for each segment.

Each inner list has the format [‘token’, ‘label1 label2 …’].

Return type

list

Example:

from sinatools.arabiner.bin import infer
infer.ner('ذهب محمد الى جامعة بيرزيت')

#the output
[['ذهب', 'O'],
['محمد', 'B-PERS'],
['الى', 'O'],
['جامعة', 'B-ORG'],
['بيرزيت', 'B-GPE I-ORG']]