'AttributeError: 'ArabertPreprocessor' object has no attribute 'farasa_segmenter'

I had this error while using AraBERT,

from arabert.preprocess import ArabertPreprocessor

model_name = "bert-base-arabertv2"
arabert_prep = ArabertPreprocessor(model_name=model_name, keep_emojis=False)

text = "ولن نبالغ إذا قلنا إن هاتف أو كمبيوتر المكتب في زمننا هذا ضروري"
arabert_prep.preprocess(text)


Solution 1:[1]

It might be that farasapy is required as per the docs, so try to install first.

It is recommended to apply our preprocessing function before training/testing on any dataset. Install farasapy to segment text for AraBERT v1 & v2 pip install farasapy

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 OmaymaS