python-negar 1.3__tar.gz → 1.4__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}/Changelog.txt +3 -0
- {python_negar-1.3 → python_negar-1.4}/PKG-INFO +5 -5
- {python_negar-1.3 → python_negar-1.4}/README.md +4 -4
- {python_negar-1.3 → python_negar-1.4}/negar/constants.py +1 -1
- {python_negar-1.3 → python_negar-1.4}/negar/virastar.py +16 -3
- {python_negar-1.3 → python_negar-1.4}/python_negar.egg-info/PKG-INFO +5 -5
- {python_negar-1.3 → python_negar-1.4}/setup.py +0 -1
- {python_negar-1.3 → python_negar-1.4}/tests/test_unittest.py +11 -5
- {python_negar-1.3 → python_negar-1.4}/AUTHORS +0 -0
- {python_negar-1.3 → python_negar-1.4}/LICENSE +0 -0
- {python_negar-1.3 → python_negar-1.4}/MANIFEST.in +0 -0
- {python_negar-1.3 → python_negar-1.4}/negar/__init__.py +0 -0
- {python_negar-1.3 → python_negar-1.4}/negar/data/immutable.words +0 -0
- {python_negar-1.3 → python_negar-1.4}/negar/gui.py +0 -0
- {python_negar-1.3 → python_negar-1.4}/python_negar.egg-info/SOURCES.txt +0 -0
- {python_negar-1.3 → python_negar-1.4}/python_negar.egg-info/dependency_links.txt +0 -0
- {python_negar-1.3 → python_negar-1.4}/python_negar.egg-info/entry_points.txt +0 -0
- {python_negar-1.3 → python_negar-1.4}/python_negar.egg-info/requires.txt +0 -0
- {python_negar-1.3 → python_negar-1.4}/python_negar.egg-info/top_level.txt +0 -0
- {python_negar-1.3 → python_negar-1.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-negar
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4
|
|
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
|
|
|
@@ -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
133
|
words = self.text.split()
|
|
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
|
|
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,11 @@ class Test(unittest.TestCase):
|
|
|
138
139
|
self.input_ = "بیستم ماه میلادی"
|
|
139
140
|
self.output_ = "بیستم ماه میلادی"
|
|
140
141
|
|
|
142
|
+
@_assertEqual("Ignote Comment")
|
|
143
|
+
def test_ignore_comment(self):
|
|
144
|
+
self.input_ = "کشیـــــــــده شده اند #> می نویسد .... "
|
|
145
|
+
self.output_ = "کشیده شدهاند #> می نویسد .... "
|
|
146
|
+
|
|
141
147
|
|
|
142
148
|
if __name__ == "__main__":
|
|
143
149
|
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
|
|
File without changes
|