kambris commited on
Commit
78da58a
ยท
verified ยท
1 Parent(s): 3f0f4b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -17
app.py CHANGED
@@ -14,23 +14,6 @@ st.set_page_config(
14
  layout="wide"
15
  )
16
  @st.cache_resource
17
- # Add Arabic stop words
18
- ARABIC_STOP_WORDS = {
19
- 'ููŠ', 'ู…ู†', 'ุฅู„ู‰', 'ุนู„ู‰', 'ุนู†', 'ู…ุน', 'ุฎู„ุงู„', 'ุญุชู‰', 'ุฅุฐุง', 'ุซู…',
20
- 'ุฃูˆ', 'ูˆ', 'ู', 'ู„', 'ุจ', 'ูƒ', 'ู„ู„', 'ุงู„', 'ู‡ุฐุง', 'ู‡ุฐู‡', 'ุฐู„ูƒ',
21
- 'ุชู„ูƒ', 'ู‡ุคู„ุงุก', 'ู‡ู…', 'ู‡ู†', 'ู‡ูˆ', 'ู‡ูŠ', 'ู†ุญู†', 'ุงู†ุช', 'ุงู†ุชู…',
22
- 'ูƒุงู†', 'ูƒุงู†ุช', 'ูŠูƒูˆู†', 'ุชูƒูˆู†', 'ุงูŠ', 'ูƒู„', 'ุจุนุถ', 'ุบูŠุฑ', 'ุญูˆู„',
23
- 'ุนู†ุฏ', 'ู‚ุฏ', 'ู„ู‚ุฏ', 'ู„ู…', 'ู„ู†', 'ู„ูˆ', 'ู…ุง', 'ู…ุงุฐุง', 'ู…ุชู‰', 'ูƒูŠู',
24
- 'ุงูŠู†', 'ู„ู…ุงุฐุง', 'ุงู„ุฐูŠ', 'ุงู„ุชูŠ', 'ุงู„ุฐูŠู†', 'ุงู„ู„ุงุชูŠ', 'ุงู„ู„ูˆุงุชูŠ',
25
- 'ุงู„ุงู†', 'ุจูŠู†', 'ููˆู‚', 'ุชุญุช', 'ุงู…ุงู…', 'ุฎู„ู', 'ุญูŠู†', 'ู‚ุจู„', 'ุจุนุฏ',
26
- 'ูˆ', 'ุฃู†', 'ููŠ', 'ูƒู„', 'ู„ู…', 'ู„ู†', 'ู„ู‡', 'ู…ู†', 'ู‡ูˆ', 'ู‡ูŠ', 'ู‚ูˆุฉ',
27
- 'ูƒู…ุง', 'ู„ู‡ุง', 'ู…ู†ุฐ', 'ูˆู‚ุฏ', 'ูˆู„ุง', 'ู†ูุณ', 'ูˆู„ู…', 'ุญูŠุซ', 'ู‡ู†ุงูƒ',
28
- 'ุฌุฏุง', 'ุฐุงุช', 'ุถู…ู†', 'ุงู†ู‡', 'ู„ุฏู‰', 'ุนู„ูŠู‡', 'ู…ุซู„', 'ูˆู„ู‡', 'ุนู†ุฏ',
29
- 'ุฃู…ุง', 'ู‡ุฐู‡', 'ูˆุฃู†', 'ูˆูƒู„', 'ูˆู‚ุงู„', 'ู„ุฏูŠ', 'ูˆูƒุงู†', 'ููŠู‡', 'ูˆู‡ูŠ',
30
- 'ูˆู‡ูˆ', 'ุชู„ูƒ', 'ูƒู„ู…', 'ู„ูƒู†', 'ูˆููŠ', 'ูˆู‚ู', 'ูˆู„ู‚ุฏ', 'ูˆู…ู†', 'ูˆู‡ุฐุง',
31
- 'ุงูˆู„', 'ุถู…ู†', 'ุงู†ู‡ุง', 'ุฌู…ูŠุน', 'ุงู„ุฐูŠ', 'ู‚ุจู„', 'ุจุนุฏ', 'ุญูˆู„', 'ุงูŠุถุง',
32
- 'ู„ุงุฒู…', 'ุญุงุฌุฉ', 'ุนู„ูŠ', 'ูŠุฌุจ', 'ุตุงุฑ', 'ุตุงุฑุช', 'ุชุญุช', 'ุถุฏ'
33
- }
34
 
35
  def load_models():
36
  """Load and cache the models to prevent reloading"""
@@ -70,6 +53,22 @@ def split_text(text, max_length=512):
70
  return chunks
71
 
72
  def clean_arabic_text(text):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  """Clean Arabic text by removing stop words and normalizing."""
74
  words = text.split()
75
  cleaned_words = [word for word in words if word not in ARABIC_STOP_WORDS and len(word) > 1]
 
14
  layout="wide"
15
  )
16
  @st.cache_resource
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  def load_models():
19
  """Load and cache the models to prevent reloading"""
 
53
  return chunks
54
 
55
  def clean_arabic_text(text):
56
+ # Add Arabic stop words
57
+ ARABIC_STOP_WORDS = {
58
+ 'ููŠ', 'ู…ู†', 'ุฅู„ู‰', 'ุนู„ู‰', 'ุนู†', 'ู…ุน', 'ุฎู„ุงู„', 'ุญุชู‰', 'ุฅุฐุง', 'ุซู…',
59
+ 'ุฃูˆ', 'ูˆ', 'ู', 'ู„', 'ุจ', 'ูƒ', 'ู„ู„', 'ุงู„', 'ู‡ุฐุง', 'ู‡ุฐู‡', 'ุฐู„ูƒ',
60
+ 'ุชู„ูƒ', 'ู‡ุคู„ุงุก', 'ู‡ู…', 'ู‡ู†', 'ู‡ูˆ', 'ู‡ูŠ', 'ู†ุญู†', 'ุงู†ุช', 'ุงู†ุชู…',
61
+ 'ูƒุงู†', 'ูƒุงู†ุช', 'ูŠูƒูˆู†', 'ุชูƒูˆู†', 'ุงูŠ', 'ูƒู„', 'ุจุนุถ', 'ุบูŠุฑ', 'ุญูˆู„',
62
+ 'ุนู†ุฏ', 'ู‚ุฏ', 'ู„ู‚ุฏ', 'ู„ู…', 'ู„ู†', 'ู„ูˆ', 'ู…ุง', 'ู…ุงุฐุง', 'ู…ุชู‰', 'ูƒูŠู',
63
+ 'ุงูŠู†', 'ู„ู…ุงุฐุง', 'ุงู„ุฐูŠ', 'ุงู„ุชูŠ', 'ุงู„ุฐูŠู†', 'ุงู„ู„ุงุชูŠ', 'ุงู„ู„ูˆุงุชูŠ',
64
+ 'ุงู„ุงู†', 'ุจูŠู†', 'ููˆู‚', 'ุชุญุช', 'ุงู…ุงู…', 'ุฎู„ู', 'ุญูŠู†', 'ู‚ุจู„', 'ุจุนุฏ',
65
+ 'ูˆ', 'ุฃู†', 'ููŠ', 'ูƒู„', 'ู„ู…', 'ู„ู†', 'ู„ู‡', 'ู…ู†', 'ู‡ูˆ', 'ู‡ูŠ', 'ู‚ูˆุฉ',
66
+ 'ูƒู…ุง', 'ู„ู‡ุง', 'ู…ู†ุฐ', 'ูˆู‚ุฏ', 'ูˆู„ุง', 'ู†ูุณ', 'ูˆู„ู…', 'ุญูŠุซ', 'ู‡ู†ุงูƒ',
67
+ 'ุฌุฏุง', 'ุฐุงุช', 'ุถู…ู†', 'ุงู†ู‡', 'ู„ุฏู‰', 'ุนู„ูŠู‡', 'ู…ุซู„', 'ูˆู„ู‡', 'ุนู†ุฏ',
68
+ 'ุฃู…ุง', 'ู‡ุฐู‡', 'ูˆุฃู†', 'ูˆูƒู„', 'ูˆู‚ุงู„', 'ู„ุฏูŠ', 'ูˆูƒุงู†', 'ููŠู‡', 'ูˆู‡ูŠ',
69
+ 'ูˆู‡ูˆ', 'ุชู„ูƒ', 'ูƒู„ู…', 'ู„ูƒู†', 'ูˆููŠ', 'ูˆู‚ู', 'ูˆู„ู‚ุฏ', 'ูˆู…ู†', 'ูˆู‡ุฐุง',
70
+ 'ุงูˆู„', 'ุถู…ู†', 'ุงู†ู‡ุง', 'ุฌู…ูŠุน', 'ุงู„ุฐูŠ', 'ู‚ุจู„', 'ุจุนุฏ', 'ุญูˆู„', 'ุงูŠุถุง',
71
+ 'ู„ุงุฒู…', 'ุญุงุฌุฉ', 'ุนู„ูŠ', 'ูŠุฌุจ', 'ุตุงุฑ', 'ุตุงุฑุช', 'ุชุญุช', 'ุถุฏ'}
72
  """Clean Arabic text by removing stop words and normalizing."""
73
  words = text.split()
74
  cleaned_words = [word for word in words if word not in ARABIC_STOP_WORDS and len(word) > 1]