ts-tokenizer 0.2.1__tar.gz → 0.2.2__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.
- {ts_tokenizer-0.2.1/ts_tokenizer.egg-info → ts_tokenizer-0.2.2}/PKG-INFO +7 -1
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/README.md +6 -0
- ts_tokenizer-0.2.2/tests/test_opening_quote_tokenization.py +56 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/__init__.py +1 -1
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/data/smileys.txt +0 -1
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/token_handler.py +65 -1
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2/ts_tokenizer.egg-info}/PKG-INFO +7 -1
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer.egg-info/SOURCES.txt +1 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/LICENSE +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/MANIFEST.in +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/pyproject.toml +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/setup.cfg +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/setup.py +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/char_fix.py +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/cli.py +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/data/TS_Corpus_Turkish_Word_List.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/data/abbr_list.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/data/cand_abbr_list.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/data/corection_mark.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/data/currency_symbols.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/data/domains.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/data/emoticons.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/data/eng_word_list.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/data/exceptions.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/data.py +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/date_check.py +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/emoticon_check.py +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/inner_punc.py +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/punctuation_process.py +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/smiley_check.py +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/tokenizer.py +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer/unit_test.py +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer.egg-info/dependency_links.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer.egg-info/entry_points.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer.egg-info/requires.txt +0 -0
- {ts_tokenizer-0.2.1 → ts_tokenizer-0.2.2}/ts_tokenizer.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ts_tokenizer
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: TS Tokenizer is a hybrid (lexicon-based and rule-based) tokenizer designed specifically for tokenizing Turkish texts.
|
|
5
5
|
Home-page: https://github.com/tanerim/ts_tokenizer
|
|
6
6
|
Author: Taner Sezer
|
|
@@ -71,6 +71,12 @@ pip install --upgrade ts-tokenizer
|
|
|
71
71
|
```
|
|
72
72
|
---
|
|
73
73
|
|
|
74
|
+
To force upgrade:
|
|
75
|
+
```bash
|
|
76
|
+
pip install --upgrade --no-cache-dir --force-reinstall ts-tokenizer
|
|
77
|
+
```
|
|
78
|
+
---
|
|
79
|
+
|
|
74
80
|
To remove package, use:
|
|
75
81
|
```bash
|
|
76
82
|
pip uninstall ts-tokenizer
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from ts_tokenizer.tokenizer import tokenize
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def tagged_lines(text):
|
|
5
|
+
return [tuple(line.split("\t")) for line in tokenize(text, "tagged").splitlines()]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_opening_double_quote_attached_to_word():
|
|
9
|
+
assert tagged_lines('"Expert') == [
|
|
10
|
+
('"', "Punc"),
|
|
11
|
+
("Expert", "English_Word"),
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_opening_single_quote_attached_to_word():
|
|
16
|
+
assert tagged_lines("'Expert") == [
|
|
17
|
+
("'", "Punc"),
|
|
18
|
+
("Expert", "English_Word"),
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_escaped_opening_single_quote_attached_to_word():
|
|
23
|
+
assert tagged_lines("\\'Expert") == [
|
|
24
|
+
("\\", "Punc"),
|
|
25
|
+
("'", "Punc"),
|
|
26
|
+
("Expert", "English_Word"),
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_quote_followed_by_space_remains_unchanged():
|
|
31
|
+
assert tagged_lines('" Expert') == [
|
|
32
|
+
('"', "Punc"),
|
|
33
|
+
("Expert", "English_Word"),
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_smiley_inside_word_is_not_split():
|
|
38
|
+
assert tagged_lines("Expertxp") == [
|
|
39
|
+
("Expertxp", "OOV"),
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_word_followed_by_smiley_is_preserved():
|
|
44
|
+
assert tagged_lines("Expert:)") == [
|
|
45
|
+
("Expert", "English_Word"),
|
|
46
|
+
(":)", "Smiley"),
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_quoted_word_followed_by_smiley_is_preserved():
|
|
51
|
+
assert tagged_lines('"Expert:)"') == [
|
|
52
|
+
('"', "Punc"),
|
|
53
|
+
("Expert", "English_Word"),
|
|
54
|
+
(":)", "Smiley"),
|
|
55
|
+
('"', "Punc"),
|
|
56
|
+
]
|
|
@@ -153,6 +153,40 @@ class TokenPreProcess:
|
|
|
153
153
|
processed_content = [processed_content]
|
|
154
154
|
return [(initial_quotes, "Punc")] + processed_content + [(final_quotes, "Punc")] if result else None
|
|
155
155
|
|
|
156
|
+
@staticmethod
|
|
157
|
+
@apply_charfix
|
|
158
|
+
def is_opening_quote(word: str) -> list:
|
|
159
|
+
if len(word) > 1 and word[0] in {'"', "'"}:
|
|
160
|
+
content = word[1:]
|
|
161
|
+
if not content:
|
|
162
|
+
return None
|
|
163
|
+
|
|
164
|
+
processed_content = TokenProcessor.process_token(content)
|
|
165
|
+
if isinstance(processed_content, tuple):
|
|
166
|
+
processed_content = [processed_content]
|
|
167
|
+
elif not isinstance(processed_content, list):
|
|
168
|
+
processed_content = [(content, "OOV")]
|
|
169
|
+
|
|
170
|
+
return [(word[0], "Punc")] + processed_content
|
|
171
|
+
return None
|
|
172
|
+
|
|
173
|
+
@staticmethod
|
|
174
|
+
@apply_charfix
|
|
175
|
+
def is_escaped_opening_quote(word: str) -> list:
|
|
176
|
+
if len(word) > 2 and word[0] == "\\" and word[1] in {'"', "'"}:
|
|
177
|
+
content = word[2:]
|
|
178
|
+
if not content:
|
|
179
|
+
return None
|
|
180
|
+
|
|
181
|
+
processed_content = TokenProcessor.process_token(content)
|
|
182
|
+
if isinstance(processed_content, tuple):
|
|
183
|
+
processed_content = [processed_content]
|
|
184
|
+
elif not isinstance(processed_content, list):
|
|
185
|
+
processed_content = [(content, "OOV")]
|
|
186
|
+
|
|
187
|
+
return [("\\", "Punc"), (word[1], "Punc")] + processed_content
|
|
188
|
+
return None
|
|
189
|
+
|
|
156
190
|
@staticmethod
|
|
157
191
|
def is_numbered_title(word: str) -> list:
|
|
158
192
|
# Check if the word matches the "numbered_title" regex pattern
|
|
@@ -491,8 +525,36 @@ class TokenPreProcess:
|
|
|
491
525
|
if not any(is_smiley for _, is_smiley in segments):
|
|
492
526
|
return None
|
|
493
527
|
|
|
528
|
+
filtered_segments = []
|
|
529
|
+
for index, (segment, is_smiley) in enumerate(segments):
|
|
530
|
+
if not is_smiley:
|
|
531
|
+
filtered_segments.append((segment, False))
|
|
532
|
+
continue
|
|
533
|
+
|
|
534
|
+
if segment.isalnum():
|
|
535
|
+
filtered_segments.append((segment, False))
|
|
536
|
+
continue
|
|
537
|
+
|
|
538
|
+
prev_char = segments[index - 1][0][-1] if index > 0 and segments[index - 1][0] else ""
|
|
539
|
+
next_char = segments[index + 1][0][0] if index + 1 < len(segments) and segments[index + 1][0] else ""
|
|
540
|
+
|
|
541
|
+
if prev_char.isalnum() and next_char.isalnum():
|
|
542
|
+
filtered_segments.append((segment, False))
|
|
543
|
+
else:
|
|
544
|
+
filtered_segments.append((segment, True))
|
|
545
|
+
|
|
546
|
+
if not any(is_smiley for _, is_smiley in filtered_segments):
|
|
547
|
+
return None
|
|
548
|
+
|
|
549
|
+
merged_segments = []
|
|
550
|
+
for segment, is_smiley in filtered_segments:
|
|
551
|
+
if merged_segments and not is_smiley and not merged_segments[-1][1]:
|
|
552
|
+
merged_segments[-1] = (merged_segments[-1][0] + segment, False)
|
|
553
|
+
else:
|
|
554
|
+
merged_segments.append((segment, is_smiley))
|
|
555
|
+
|
|
494
556
|
tokens = []
|
|
495
|
-
for segment, is_smiley in
|
|
557
|
+
for segment, is_smiley in merged_segments:
|
|
496
558
|
if is_smiley:
|
|
497
559
|
tokens.append((segment, "Smiley"))
|
|
498
560
|
continue
|
|
@@ -1109,6 +1171,8 @@ regex = [
|
|
|
1109
1171
|
TokenPreProcess.is_mention,
|
|
1110
1172
|
TokenPreProcess.is_hashtag,
|
|
1111
1173
|
TokenPreProcess.is_in_quotes,
|
|
1174
|
+
TokenPreProcess.is_escaped_opening_quote,
|
|
1175
|
+
TokenPreProcess.is_opening_quote,
|
|
1112
1176
|
TokenPreProcess.is_apostrophed,
|
|
1113
1177
|
TokenPreProcess.is_numbered_title,
|
|
1114
1178
|
TokenPreProcess.is_parenthesized_with_trailing_colon,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ts_tokenizer
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: TS Tokenizer is a hybrid (lexicon-based and rule-based) tokenizer designed specifically for tokenizing Turkish texts.
|
|
5
5
|
Home-page: https://github.com/tanerim/ts_tokenizer
|
|
6
6
|
Author: Taner Sezer
|
|
@@ -71,6 +71,12 @@ pip install --upgrade ts-tokenizer
|
|
|
71
71
|
```
|
|
72
72
|
---
|
|
73
73
|
|
|
74
|
+
To force upgrade:
|
|
75
|
+
```bash
|
|
76
|
+
pip install --upgrade --no-cache-dir --force-reinstall ts-tokenizer
|
|
77
|
+
```
|
|
78
|
+
---
|
|
79
|
+
|
|
74
80
|
To remove package, use:
|
|
75
81
|
```bash
|
|
76
82
|
pip uninstall ts-tokenizer
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|