python-negar 1.4.1__tar.gz → 1.4.3__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.
@@ -1,3 +1,9 @@
1
+ 1.4.3 - 2025-01-28
2
+ -- Save user defined immutable words under .config/python-negar
3
+
4
+ 1.4.2 - 2025-01-23
5
+ -- Fixed issue with همان‌طور، نشان‌دهنده
6
+
1
7
  1.4.1 - 2025-01-06
2
8
  -- Fixed issue with immutability check.
3
9
  -- Added several additional immutable words.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-negar
3
- Version: 1.4.1
3
+ Version: 1.4.3
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
@@ -1,10 +1,10 @@
1
1
  import platform
2
2
  from pathlib import Path
3
3
 
4
- __version__ = "1.4.1"
4
+ __version__ = "1.4.3"
5
5
 
6
6
  DATAFILE = Path(__file__).parent.absolute() / "data/immutable.words"
7
- APPDATA = "AppData/Roaming/" if platform.system() == "Windows" else "."
7
+ APPDATA = "AppData/Roaming/" if platform.system() == "Windows" else ".config/"
8
8
  USERFILE = Path.home() / f"{APPDATA}python-negar"
9
9
 
10
10
  INFO = f"""قابلیت های ویراستار ' نگار ' -- نسخه {__version__} :
@@ -5,6 +5,7 @@ import enum
5
5
  import re
6
6
  import sys
7
7
  from pathlib import Path
8
+ from contextlib import suppress
8
9
 
9
10
  import regex
10
11
 
@@ -259,7 +260,7 @@ class PersianEditor:
259
260
  if self._exaggerating_zwnj
260
261
  else ""
261
262
  )
262
- regx = re.compile(
263
+ regx = regex.compile(
263
264
  rf"""\b(\S+?) # not-greedy fetch to handle some case like هایشان instead شان
264
265
  ({exag}
265
266
  # تر(ی(ن)?)?
@@ -267,13 +268,13 @@ class PersianEditor:
267
268
  # ها(ی(ی|ت|م|ش|تان|شان)?)?|
268
269
  شناس(ی)?|
269
270
  گذار(ی)?|گزار(ی)?
270
- )\b""",
271
+ )(?:(?=\b)|(?=\u200C))""", # ensures that it is followed by either \b or \u200C
271
272
  re.VERBOSE,
272
273
  )
273
274
  # Checks that the suffix (tar*, haye*) is part of a word or not, like بهتر.
274
275
  self.__immutability_check__(regx)
275
276
 
276
- def __immutability_check__(self, regx: re.Pattern):
277
+ def __immutability_check__(self, regx: regex.Pattern):
277
278
  # Replace backslashes with a temporary placeholder
278
279
  text = self.text.replace("\\", "PN__BACKSLASH__PN")
279
280
  wlist = text.split()
@@ -281,7 +282,7 @@ class PersianEditor:
281
282
  regx_iter = regx.finditer(word)
282
283
  for p in regx_iter:
283
284
  # if p.group() not in ImmutableWords.get():
284
- text = re.sub(
285
+ text = regex.sub(
285
286
  rf"\b{re.escape(p.group())}\b",
286
287
  p.group(1) + "\u200c" + p.group(2),
287
288
  text,
@@ -389,15 +390,14 @@ class ImmutableWords:
389
390
  with DATAFILE.open(encoding="utf8") as f:
390
391
  for line in f:
391
392
  cls.words.add(line.strip())
392
- try:
393
- # for compatibility with previous versions, since immutable.words was untouchable.dat before ver 1.2.10
394
- if (USERFILE / "untouchable.dat").exists():
395
- (USERFILE / "untouchable.dat").rename(USERFILE / "immutable.words")
393
+
394
+ # for compatibility with previous versions, since immutable.words was untouchable.dat before ver 1.2.10
395
+ if (USERFILE / "untouchable.dat").exists():
396
+ (USERFILE / "untouchable.dat").rename(USERFILE / "immutable.words")
397
+ with suppress(FileNotFoundError):
396
398
  with (USERFILE / "immutable.words").open(encoding="utf8") as f:
397
399
  for line in f:
398
400
  cls.words.add(line.strip())
399
- except FileNotFoundError:
400
- pass
401
401
 
402
402
 
403
403
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-negar
3
- Version: 1.4.1
3
+ Version: 1.4.3
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
@@ -149,6 +149,11 @@ class Test(unittest.TestCase):
149
149
  self.input_ = '"دختر تنهایی " ( کهتر بمان )'
150
150
  self.output_ = "«دختر تنهایی» (کهتر بمان)"
151
151
 
152
+ @_assertEqual("unchanged")
153
+ def test_unchanged(self):
154
+ self.input_ = "نشان‌دهنده همان‌طور"
155
+ self.output_ = "نشان‌دهنده همان‌طور"
156
+
152
157
 
153
158
  if __name__ == "__main__":
154
159
  unittest.main()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes