sinatools.utils.parser

sinatools.utils.parser.arStrip(text, diacs=True, small_diacs=True, shaddah=True, digit=True, alif=True, special_chars=True)

This method removes Arabic diacritics, small diacritcs, shaddah, Latin and Arabic digits, unify alif, remove special characters, extra spaces, underscore and Arabic tatwelah from the input text.

Parameters
  • text (str) – Arabic text to be processed.

  • diacs (bool) – flag to remove Arabic diacretics [ ًٌٍَُِْ] (default is True).

  • small_diacs (bool) – flag to remove small diacretics (default is True).

  • shaddah (bool) – flag to remove shaddah (default is True).

  • digit (bool) – flag to remove Latin and Arabic digits (default is True).

  • alif (bool) – flag to unify alif (default is True).

  • special_chars (bool) – flag to remove special characters (default is True).

Returns

stripped text.

Return type

str

Example:

from sinatools.utils import parser
output =parser.arStrip('2023الجو جميلُ')
print(output)

#output
الجو جميل

output =parser.arStrip('أَلَمۡ یَأۡنِ لِلَّذِینَ ءَامَنُوۤا۟ أَن تَخۡشَعَ قُلُوبُهُمۡ لِذِكۡرِ ٱللَّهِ وَمَا نَزَلَ مِنَ ٱلۡحَقِّ وَلَا یَكُونُوا۟ كَٱلَّذِینَ أُوتُوا۟ ٱلۡكِتَـٰبَ مِن قَبۡلُ فَطَالَ عَلَیۡهِمُ ٱلۡأَمَدُ فَقَسَتۡ قُلُوبُهُمۡۖ وَكَثِیر مِّنۡهُمۡ فَـسِقُونَ' , True , True , True ,  True , True , True )
print(output)
#output
الم یان للذین ءامنوا ان تخشع قلوبهم لذكر الله وما نزل من الحق ولا یكونوا كالذین اوتوا الكتٰب من قبل فطال علیهم الامد فقست قلوبهم وكثیر منهم فسقون
sinatools.utils.parser.remove_latin(text)

This method removes all Latin characters from the input text.

Parameters

text (str) – The input text.

Returns

The text without Latin characters.

Return type

str

Note

If an error occurs during processing, the original text is returned.

Example:

from sinatools.utils import parser
output = parser.remove_latin("miojkdujhvaj1546545spkdpoqfoiehwv nWEQFGWERHERTJETAWIKUYFC")
print(output)
  
#output
1546545
  
output= parser.remove_latin("أصل المسمى «تخطيط موارد المؤسسة» هو تعريب لمسمى التخطيط باللغة الإنجليزية Enterprise Resource Planning")
print(output)
  
#output
أصل المسمى «تخطيط موارد المؤسسة» هو تعريب لمسمى التخطيط باللغة الإنجليزية
sinatools.utils.parser.remove_punctuation(text)

Removes punctuation marks from the text.

Parameters

text (str) – The input text.

Returns

The output text without punctuation marks.

Return type

str

Example:

from sinatools.utils import parser
output = parser.remove_punctuation("te!@#،$%%؟st")
print(output)

#output
test

output= parser.remove_punctuation(" {يَا أَيُّهَا الَّذِينَ آمَنُوا لِيَسْتَأْذِنْكُمُ ....}")
print(output)

#output
يَا أَيُّهَا الَّذِينَ آمَنُوا لِيَسْتَأْذِنْكُمُ