python-negar 1.3__tar.gz → 1.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_negar-1.3 → python_negar-1.4.1}/Changelog.txt +7 -0
- {python_negar-1.3 → python_negar-1.4.1}/PKG-INFO +5 -5
- {python_negar-1.3 → python_negar-1.4.1}/README.md +4 -4
- {python_negar-1.3 → python_negar-1.4.1}/negar/constants.py +1 -1
- {python_negar-1.3 → python_negar-1.4.1}/negar/data/immutable.words +24 -0
- {python_negar-1.3 → python_negar-1.4.1}/negar/virastar.py +17 -4
- {python_negar-1.3 → python_negar-1.4.1}/python_negar.egg-info/PKG-INFO +5 -5
- {python_negar-1.3 → python_negar-1.4.1}/setup.py +0 -1
- {python_negar-1.3 → python_negar-1.4.1}/tests/test_unittest.py +16 -5
- {python_negar-1.3 → python_negar-1.4.1}/AUTHORS +0 -0
- {python_negar-1.3 → python_negar-1.4.1}/LICENSE +0 -0
- {python_negar-1.3 → python_negar-1.4.1}/MANIFEST.in +0 -0
- {python_negar-1.3 → python_negar-1.4.1}/negar/__init__.py +0 -0
- {python_negar-1.3 → python_negar-1.4.1}/negar/gui.py +0 -0
- {python_negar-1.3 → python_negar-1.4.1}/python_negar.egg-info/SOURCES.txt +0 -0
- {python_negar-1.3 → python_negar-1.4.1}/python_negar.egg-info/dependency_links.txt +0 -0
- {python_negar-1.3 → python_negar-1.4.1}/python_negar.egg-info/entry_points.txt +0 -0
- {python_negar-1.3 → python_negar-1.4.1}/python_negar.egg-info/requires.txt +0 -0
- {python_negar-1.3 → python_negar-1.4.1}/python_negar.egg-info/top_level.txt +0 -0
- {python_negar-1.3 → python_negar-1.4.1}/setup.cfg +0 -0
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
1.4.1 - 2025-01-06
|
|
2
|
+
-- Fixed issue with immutability check.
|
|
3
|
+
-- Added several additional immutable words.
|
|
4
|
+
|
|
5
|
+
1.4 - 2025-01-05
|
|
6
|
+
-- Added a new feature to ignore text after #> as a comment trigger.
|
|
7
|
+
|
|
1
8
|
1.3 - 2025-01-01
|
|
2
9
|
-- Enhanced the handling of immutable words to achieve greater accuracy in results.
|
|
3
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-negar
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: Negar is a spell corrector and Persian text editor
|
|
5
5
|
Home-page: http://github.com/shahinism/python-negar
|
|
6
6
|
Author: Shahin Azad
|
|
@@ -42,7 +42,7 @@ Installation
|
|
|
42
42
|
|
|
43
43
|
## Git
|
|
44
44
|
|
|
45
|
-
You can get latest stable changes from
|
|
45
|
+
You can get the latest stable changes from the GitHub server:
|
|
46
46
|
|
|
47
47
|
$ git clone https://github.com/shahinism/python-negar.git
|
|
48
48
|
$ cd python-negar
|
|
@@ -62,11 +62,11 @@ Get the latest tarball & install:
|
|
|
62
62
|
|
|
63
63
|
### Windows
|
|
64
64
|
|
|
65
|
-
Download latest zip archive.
|
|
65
|
+
Download the latest zip archive.
|
|
66
66
|
|
|
67
67
|
https://github.com/shahinism/python-negar/archive/master.zip
|
|
68
68
|
|
|
69
|
-
Decompress it, and run the following command in root directory of `python-negar`
|
|
69
|
+
Decompress it, and run the following command in the root directory of `python-negar`
|
|
70
70
|
|
|
71
71
|
$ python setup.py install
|
|
72
72
|
|
|
@@ -85,7 +85,7 @@ Calling by default options:
|
|
|
85
85
|
* جایگزینی
|
|
86
86
|
+ خط تیره های پیاپی نظیر (--) و (---) با معادل های استاندارد شان
|
|
87
87
|
+ سه نقطه ی پیاپی (...) با کاراکتر استانداردش در زبان فارسی
|
|
88
|
-
+ علایمی نظیر
|
|
88
|
+
+ علایمی نظیر کوتیشن فارسی با گیومه ؛ 'نگار'
|
|
89
89
|
+ اعداد عربی '١٢٣٤٥٦٧٨٩٠' و انگلیسی '1234567890' با معادل فارسی
|
|
90
90
|
+ کاراکتر های غیر فارسی نظیر ',;%يةك' با معادل های فارسی
|
|
91
91
|
|
|
@@ -21,7 +21,7 @@ Installation
|
|
|
21
21
|
|
|
22
22
|
## Git
|
|
23
23
|
|
|
24
|
-
You can get latest stable changes from
|
|
24
|
+
You can get the latest stable changes from the GitHub server:
|
|
25
25
|
|
|
26
26
|
$ git clone https://github.com/shahinism/python-negar.git
|
|
27
27
|
$ cd python-negar
|
|
@@ -41,11 +41,11 @@ Get the latest tarball & install:
|
|
|
41
41
|
|
|
42
42
|
### Windows
|
|
43
43
|
|
|
44
|
-
Download latest zip archive.
|
|
44
|
+
Download the latest zip archive.
|
|
45
45
|
|
|
46
46
|
https://github.com/shahinism/python-negar/archive/master.zip
|
|
47
47
|
|
|
48
|
-
Decompress it, and run the following command in root directory of `python-negar`
|
|
48
|
+
Decompress it, and run the following command in the root directory of `python-negar`
|
|
49
49
|
|
|
50
50
|
$ python setup.py install
|
|
51
51
|
|
|
@@ -64,7 +64,7 @@ Calling by default options:
|
|
|
64
64
|
* جایگزینی
|
|
65
65
|
+ خط تیره های پیاپی نظیر (--) و (---) با معادل های استاندارد شان
|
|
66
66
|
+ سه نقطه ی پیاپی (...) با کاراکتر استانداردش در زبان فارسی
|
|
67
|
-
+ علایمی نظیر
|
|
67
|
+
+ علایمی نظیر کوتیشن فارسی با گیومه ؛ 'نگار'
|
|
68
68
|
+ اعداد عربی '١٢٣٤٥٦٧٨٩٠' و انگلیسی '1234567890' با معادل فارسی
|
|
69
69
|
+ کاراکتر های غیر فارسی نظیر ',;%يةك' با معادل های فارسی
|
|
70
70
|
|
|
@@ -194,6 +194,8 @@
|
|
|
194
194
|
بلغارستان
|
|
195
195
|
بلوچستان
|
|
196
196
|
بلوچستان
|
|
197
|
+
بمان
|
|
198
|
+
بمانی
|
|
197
199
|
بنانها
|
|
198
200
|
بنگستان
|
|
199
201
|
بنگستان
|
|
@@ -213,6 +215,8 @@
|
|
|
213
215
|
بهترین
|
|
214
216
|
بهتنهایی
|
|
215
217
|
بهمان
|
|
218
|
+
بهمان
|
|
219
|
+
بهمانی
|
|
216
220
|
بوتان
|
|
217
221
|
بودنتان
|
|
218
222
|
بوستان
|
|
@@ -337,6 +341,9 @@
|
|
|
337
341
|
بیبل
|
|
338
342
|
بیبها
|
|
339
343
|
بیبهایی
|
|
344
|
+
بیبی
|
|
345
|
+
بیبیفیس
|
|
346
|
+
بیبیگرل
|
|
340
347
|
بیت
|
|
341
348
|
بیتالتکمهها
|
|
342
349
|
بیتالحکمه
|
|
@@ -416,6 +423,7 @@
|
|
|
416
423
|
بیدی
|
|
417
424
|
بیر
|
|
418
425
|
بیرالده
|
|
426
|
+
بیرانوند
|
|
419
427
|
بیراه
|
|
420
428
|
بیراهه
|
|
421
429
|
بیراههها
|
|
@@ -800,6 +808,7 @@
|
|
|
800
808
|
پاکنها
|
|
801
809
|
پانسمان
|
|
802
810
|
پایتان
|
|
811
|
+
پخشان
|
|
803
812
|
پراستر
|
|
804
813
|
پراشتها
|
|
805
814
|
پرالتها
|
|
@@ -883,6 +892,9 @@
|
|
|
883
892
|
تنهای
|
|
884
893
|
تنهایی
|
|
885
894
|
تنهایی
|
|
895
|
+
تنهاییها
|
|
896
|
+
تنهاییهای
|
|
897
|
+
تنهاییهایی
|
|
886
898
|
تنورهکشان
|
|
887
899
|
تهیدستان
|
|
888
900
|
توتستان
|
|
@@ -910,8 +922,15 @@
|
|
|
910
922
|
چایمان
|
|
911
923
|
چپدستان
|
|
912
924
|
چچستان
|
|
925
|
+
چشمانتان
|
|
926
|
+
چشمانتان
|
|
927
|
+
چشمانشان
|
|
928
|
+
چشمانشان
|
|
929
|
+
چشمانمان
|
|
930
|
+
چشمانمان
|
|
913
931
|
چنارستان
|
|
914
932
|
چیستان
|
|
933
|
+
حاکمان
|
|
915
934
|
حرفتان
|
|
916
935
|
حسابتان
|
|
917
936
|
حصیرستان
|
|
@@ -978,6 +997,7 @@
|
|
|
978
997
|
دفتری
|
|
979
998
|
دکتر
|
|
980
999
|
دکتری
|
|
1000
|
+
دکترین
|
|
981
1001
|
دلستر
|
|
982
1002
|
دنیاپرستان
|
|
983
1003
|
دهستان
|
|
@@ -1065,6 +1085,8 @@
|
|
|
1065
1085
|
شبستری
|
|
1066
1086
|
شبها
|
|
1067
1087
|
شتان
|
|
1088
|
+
شتر
|
|
1089
|
+
شتری
|
|
1068
1090
|
شعردوستان
|
|
1069
1091
|
شفها
|
|
1070
1092
|
شکرافشان
|
|
@@ -1860,6 +1882,8 @@
|
|
|
1860
1882
|
هلیکوپتر
|
|
1861
1883
|
هلیکوپتر
|
|
1862
1884
|
همان
|
|
1885
|
+
همان
|
|
1886
|
+
همانها
|
|
1863
1887
|
همانی
|
|
1864
1888
|
همبستر
|
|
1865
1889
|
همپیمان
|
|
@@ -57,6 +57,7 @@ class PersianEditor:
|
|
|
57
57
|
self.cleanup()
|
|
58
58
|
|
|
59
59
|
def cleanup(self):
|
|
60
|
+
self.__handle_comments__(State.save)
|
|
60
61
|
self.__handle_urls__(State.save)
|
|
61
62
|
# fix punctuation spaces at first
|
|
62
63
|
# : ; , ! ? and their Persian counterparts should have one space after and no space before
|
|
@@ -95,6 +96,7 @@ class PersianEditor:
|
|
|
95
96
|
if self._trim_leading_trailing_whitespaces:
|
|
96
97
|
self.text = "\n".join([line.strip() for line in self.text.split("\n")])
|
|
97
98
|
self.__handle_urls__(State.restore)
|
|
99
|
+
self.__handle_comments__(State.restore)
|
|
98
100
|
return self.text
|
|
99
101
|
|
|
100
102
|
def __repr__(self):
|
|
@@ -102,8 +104,19 @@ class PersianEditor:
|
|
|
102
104
|
|
|
103
105
|
__str__ = __repr__
|
|
104
106
|
|
|
107
|
+
def __handle_comments__(self, state):
|
|
108
|
+
"""Extract comments, process the content, and reinsert the comments at the end."""
|
|
109
|
+
if state == State.save:
|
|
110
|
+
self.comments = list(set(re.findall(r"#>.*$", self.text, re.I | re.M)))
|
|
111
|
+
self.comments.sort(key=lambda x: len(x), reverse=True)
|
|
112
|
+
for i, comment in enumerate(self.comments):
|
|
113
|
+
self.text = regex.sub(rf"{re.escape(comment)}", rf"__COMMENT__#{i}__", self.text)
|
|
114
|
+
if state == State.restore:
|
|
115
|
+
for i, comment in enumerate(self.comments):
|
|
116
|
+
self.text = re.sub(f"__COMMENT__#{i}__", comment, self.text)
|
|
117
|
+
|
|
105
118
|
def __handle_urls__(self, state):
|
|
106
|
-
"""Remove URLs and
|
|
119
|
+
"""Remove URLs temporarily and reinsert them at the end of the process."""
|
|
107
120
|
if state == State.save:
|
|
108
121
|
self.urls = list(set(re.findall(URLREGX, self.text, re.M | re.I | re.X)))
|
|
109
122
|
self.urls.sort(key=lambda x: len(x), reverse=True)
|
|
@@ -114,12 +127,12 @@ class PersianEditor:
|
|
|
114
127
|
self.text = re.sub(f"__URL__#{i}__", url, self.text)
|
|
115
128
|
|
|
116
129
|
def __handle_immutable_words__(self, state):
|
|
117
|
-
"""Remove
|
|
130
|
+
"""Remove immutable words temporarily and reapply them at the end of the process."""
|
|
118
131
|
if state == State.save:
|
|
119
132
|
self.immutable_words = {}
|
|
120
|
-
words = self.text.
|
|
133
|
+
words = re.findall(r"\b[\w\u200c]+\b", self.text, re.UNICODE)
|
|
121
134
|
for i, word in enumerate(words):
|
|
122
|
-
if (word:=word.strip()) in ImmutableWords.get():
|
|
135
|
+
if (word := word.strip()) in ImmutableWords.get():
|
|
123
136
|
self.immutable_words[i] = word
|
|
124
137
|
self.text = regex.sub(rf"\b{word}\b", rf"__IMM__#{i}__", self.text)
|
|
125
138
|
if state == State.restore:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-negar
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: Negar is a spell corrector and Persian text editor
|
|
5
5
|
Home-page: http://github.com/shahinism/python-negar
|
|
6
6
|
Author: Shahin Azad
|
|
@@ -42,7 +42,7 @@ Installation
|
|
|
42
42
|
|
|
43
43
|
## Git
|
|
44
44
|
|
|
45
|
-
You can get latest stable changes from
|
|
45
|
+
You can get the latest stable changes from the GitHub server:
|
|
46
46
|
|
|
47
47
|
$ git clone https://github.com/shahinism/python-negar.git
|
|
48
48
|
$ cd python-negar
|
|
@@ -62,11 +62,11 @@ Get the latest tarball & install:
|
|
|
62
62
|
|
|
63
63
|
### Windows
|
|
64
64
|
|
|
65
|
-
Download latest zip archive.
|
|
65
|
+
Download the latest zip archive.
|
|
66
66
|
|
|
67
67
|
https://github.com/shahinism/python-negar/archive/master.zip
|
|
68
68
|
|
|
69
|
-
Decompress it, and run the following command in root directory of `python-negar`
|
|
69
|
+
Decompress it, and run the following command in the root directory of `python-negar`
|
|
70
70
|
|
|
71
71
|
$ python setup.py install
|
|
72
72
|
|
|
@@ -85,7 +85,7 @@ Calling by default options:
|
|
|
85
85
|
* جایگزینی
|
|
86
86
|
+ خط تیره های پیاپی نظیر (--) و (---) با معادل های استاندارد شان
|
|
87
87
|
+ سه نقطه ی پیاپی (...) با کاراکتر استانداردش در زبان فارسی
|
|
88
|
-
+ علایمی نظیر
|
|
88
|
+
+ علایمی نظیر کوتیشن فارسی با گیومه ؛ 'نگار'
|
|
89
89
|
+ اعداد عربی '١٢٣٤٥٦٧٨٩٠' و انگلیسی '1234567890' با معادل فارسی
|
|
90
90
|
+ کاراکتر های غیر فارسی نظیر ',;%يةك' با معادل های فارسی
|
|
91
91
|
|
|
@@ -11,7 +11,9 @@ class Test(unittest.TestCase):
|
|
|
11
11
|
def wrapper(self, *args, **kwargs):
|
|
12
12
|
func(self, *args, **kwargs)
|
|
13
13
|
return self.assertEqual(f"{PersianEditor(self.input_)}", self.output_, message)
|
|
14
|
+
|
|
14
15
|
return wrapper
|
|
16
|
+
|
|
15
17
|
return decorator
|
|
16
18
|
|
|
17
19
|
# @unittest.skip("")
|
|
@@ -22,8 +24,8 @@ class Test(unittest.TestCase):
|
|
|
22
24
|
|
|
23
25
|
@_assertEqual("Fix Hamzeh")
|
|
24
26
|
def test_fix_hamzeh(self):
|
|
25
|
-
self.input_ = "کلماتی که با 'ی' پسوند همراه هستند مانند 'همه ی ' -- و البته امکان جایگزینی آن با حمزه 'ء' ( در صورت انتخاب کاربر )"
|
|
26
|
-
self.output_ = "کلماتی که با «ی» پسوند همراه هستند مانند «همهی» – و البته امکان جایگزینی آن با حمزه «ء» (در صورت انتخاب کاربر)"
|
|
27
|
+
self.input_ = "کلماتی که با 'ی' پسوند همراه هستند مانند 'همه ی ' -- و البته امکان جایگزینی آن با حمزه 'ء' ( در صورت انتخاب کاربر )" # noqa: E501
|
|
28
|
+
self.output_ = "کلماتی که با «ی» پسوند همراه هستند مانند «همهی» – و البته امکان جایگزینی آن با حمزه «ء» (در صورت انتخاب کاربر)" # noqa: E501
|
|
27
29
|
|
|
28
30
|
@_assertEqual("Numbers as a Version -- Triple Dots")
|
|
29
31
|
def test_versioning_numbers_triple(self):
|
|
@@ -61,7 +63,6 @@ class Test(unittest.TestCase):
|
|
|
61
63
|
def test_persian_quotations_ii(self):
|
|
62
64
|
self.input_ = "«تاثیر نسبی داشته است. »"
|
|
63
65
|
self.output_ = "«تاثیر نسبی داشته است.»"
|
|
64
|
-
|
|
65
66
|
|
|
66
67
|
@_assertEqual("Persian Numbers")
|
|
67
68
|
def test_persian_numbers(self):
|
|
@@ -102,7 +103,7 @@ class Test(unittest.TestCase):
|
|
|
102
103
|
def test_fix_prefix_ZWNJ_iii(self):
|
|
103
104
|
self.input_ = r"می شود"
|
|
104
105
|
self.output_ = "میشود"
|
|
105
|
-
|
|
106
|
+
|
|
106
107
|
@_assertEqual("Fix Suffix ZWNJ I")
|
|
107
108
|
def test_fix_suffix_ZWNJ_I(self):
|
|
108
109
|
self.input_ = r"در پسوند کلمات با نیمفاصله نظیر کتابها، خوشترین -- و البته امکان عدم تنظیم (در صورت انتخاب کاربر)"
|
|
@@ -127,7 +128,7 @@ class Test(unittest.TestCase):
|
|
|
127
128
|
def test_immutable_words_i(self):
|
|
128
129
|
self.input_ = "تنها ترین خدمتگزار (تنها ترین خدمتگزار)"
|
|
129
130
|
self.output_ = "تنهاترین خدمتگزار (تنهاترین خدمتگزار)"
|
|
130
|
-
|
|
131
|
+
|
|
131
132
|
@_assertEqual("Immutable Words II")
|
|
132
133
|
def test_immutable_words_ii(self):
|
|
133
134
|
self.input_ = "تنها ترین خدمتگزار (تنها ترین خدمتگزار)"
|
|
@@ -138,6 +139,16 @@ class Test(unittest.TestCase):
|
|
|
138
139
|
self.input_ = "بیستم ماه میلادی"
|
|
139
140
|
self.output_ = "بیستم ماه میلادی"
|
|
140
141
|
|
|
142
|
+
@_assertEqual("Ignore Comment")
|
|
143
|
+
def test_ignore_comment(self):
|
|
144
|
+
self.input_ = "کشیـــــــــده شده اند #> می نویسد .... "
|
|
145
|
+
self.output_ = "کشیده شدهاند #> می نویسد .... "
|
|
146
|
+
|
|
147
|
+
@_assertEqual("mix_parentheses_suffix")
|
|
148
|
+
def test_mix_parentheses_suffix(self):
|
|
149
|
+
self.input_ = '"دختر تنهایی " ( کهتر بمان )'
|
|
150
|
+
self.output_ = "«دختر تنهایی» (کهتر بمان)"
|
|
151
|
+
|
|
141
152
|
|
|
142
153
|
if __name__ == "__main__":
|
|
143
154
|
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|