e2k 0.2.2__tar.gz → 0.3.0__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,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: e2k
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Summary: A tool for automatic English to Katakana conversion
5
5
  Author-email: Patchethium <asguftuikh@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -37,20 +37,31 @@ p2k = P2K()
37
37
 
38
38
  g2p = G2p()
39
39
 
40
- katakana = p2k(g2p("word"))
40
+ word = "word"
41
+
42
+ word = word.lower()
43
+
44
+ # you can check the accepted symbols using
45
+ in_table = c2k.in_table # `c2k` accepts lowercase characters, space and apostrophe
46
+ in_table = p2k.in_table # `p2k` accepts the phonemes from the CMUdict and space
47
+ # for output symbols
48
+ out_table = c2k.out_table
49
+ out_table = p2k.out_table
50
+
51
+ katakana = p2k(g2p(word))
41
52
 
42
53
  print(katakana) # "ワード"
43
54
 
44
- # character directly to katakana
55
+ # characters directly to katakana
45
56
  c2k = C2K()
46
57
 
47
- katakana = c2k("word")
58
+ katakana = c2k(word)
48
59
 
49
60
  print(katakana) # "ワード"
50
61
 
51
62
  # decode strategy
52
63
  # greedy by default, top_k and top_p are available
53
- # TODO: beam searh
64
+ # I tried implementing beam search but it barely differs from greedy
54
65
  c2k.set_decode_strategy("top_k", top_k=2) # low quality results, not recommended
55
66
  c2k.set_decode_strategy("top_p", top_p=0.6, t=0.8)
56
67
  # for further information, see
@@ -58,14 +69,17 @@ c2k.set_decode_strategy("top_p", top_p=0.6, t=0.8)
58
69
  print(katakana) # "ワード"
59
70
  ```
60
71
 
72
+ > [!WARNING]
73
+ > For any symbols not in the `in_table`, the model will ignore them and may produce unexpected results.
74
+
61
75
  ### Performance
62
76
 
63
77
  The BLEU score is calculated on a random subset with size of 10% of the dataset.
64
78
 
65
79
  | Model | BLEU Score ↑ |
66
80
  | ----- | ------------ |
67
- | P2K | 0.87 |
68
- | C2K | 0.91 |
81
+ | P2K | 0.89 |
82
+ | C2K | 0.92 |
69
83
 
70
84
  ## Dictionary
71
85
 
@@ -164,10 +178,10 @@ The model should be exported to `numpy` format for production use.
164
178
 
165
179
  ```bash
166
180
  # --p2k for phoneme to katakana, if not provided, it will be character to katakana
167
- # --fp16 for half precision, there's no reason not to use it
181
+ # --fp32 for double precision, by default we use fp16 to save space
168
182
  # --output to specify the output file, in this project it's `model-{p2k/c2k}.npz`
169
183
  # --safetenors to use safe tensors, it's for easier binding in some languages
170
- python export.py --model /path/to/your/model.pth --p2k --fp16 --output /path/to/your/model.npz
184
+ python export.py --model /path/to/your/model.pth --p2k --output /path/to/your/model.npz
171
185
  ```
172
186
 
173
187
  > [!Note]
@@ -175,13 +189,10 @@ python export.py --model /path/to/your/model.pth --p2k --fp16 --output /path/to/
175
189
 
176
190
  ## License
177
191
 
178
- The code is released under WTFPL, you can do WTF you want with it.
179
-
180
- The dictionary should follow the [Wikimedia's license](https://dumps.wikimedia.org/legal.html) and the [JMdict / EDICT's Copyright](https://www.edrdg.org/) license.
181
-
182
- In short, as long as you provide the attribution, you can use it for both commercial and non-commercial purposes.
183
-
184
- The model weights are released under the same license as the dictionary.
192
+ - The code is released under WTFPL, you can do WTF you want with it.
193
+ - The dictionary follows the [Wikimedia's license](https://dumps.wikimedia.org/legal.html) and the [JMdict / EDICT's Copyright](https://www.edrdg.org/) license.
194
+ - In short, they both fall into CC-BY-SA.
195
+ - The model weights are trained using the dictionary. I am not a lawyer, whether the machine learning weights is considered as a derivative work is up to you.
185
196
 
186
197
  ## Credits
187
198
 
@@ -28,20 +28,31 @@ p2k = P2K()
28
28
 
29
29
  g2p = G2p()
30
30
 
31
- katakana = p2k(g2p("word"))
31
+ word = "word"
32
+
33
+ word = word.lower()
34
+
35
+ # you can check the accepted symbols using
36
+ in_table = c2k.in_table # `c2k` accepts lowercase characters, space and apostrophe
37
+ in_table = p2k.in_table # `p2k` accepts the phonemes from the CMUdict and space
38
+ # for output symbols
39
+ out_table = c2k.out_table
40
+ out_table = p2k.out_table
41
+
42
+ katakana = p2k(g2p(word))
32
43
 
33
44
  print(katakana) # "ワード"
34
45
 
35
- # character directly to katakana
46
+ # characters directly to katakana
36
47
  c2k = C2K()
37
48
 
38
- katakana = c2k("word")
49
+ katakana = c2k(word)
39
50
 
40
51
  print(katakana) # "ワード"
41
52
 
42
53
  # decode strategy
43
54
  # greedy by default, top_k and top_p are available
44
- # TODO: beam searh
55
+ # I tried implementing beam search but it barely differs from greedy
45
56
  c2k.set_decode_strategy("top_k", top_k=2) # low quality results, not recommended
46
57
  c2k.set_decode_strategy("top_p", top_p=0.6, t=0.8)
47
58
  # for further information, see
@@ -49,14 +60,17 @@ c2k.set_decode_strategy("top_p", top_p=0.6, t=0.8)
49
60
  print(katakana) # "ワード"
50
61
  ```
51
62
 
63
+ > [!WARNING]
64
+ > For any symbols not in the `in_table`, the model will ignore them and may produce unexpected results.
65
+
52
66
  ### Performance
53
67
 
54
68
  The BLEU score is calculated on a random subset with size of 10% of the dataset.
55
69
 
56
70
  | Model | BLEU Score ↑ |
57
71
  | ----- | ------------ |
58
- | P2K | 0.87 |
59
- | C2K | 0.91 |
72
+ | P2K | 0.89 |
73
+ | C2K | 0.92 |
60
74
 
61
75
  ## Dictionary
62
76
 
@@ -155,10 +169,10 @@ The model should be exported to `numpy` format for production use.
155
169
 
156
170
  ```bash
157
171
  # --p2k for phoneme to katakana, if not provided, it will be character to katakana
158
- # --fp16 for half precision, there's no reason not to use it
172
+ # --fp32 for double precision, by default we use fp16 to save space
159
173
  # --output to specify the output file, in this project it's `model-{p2k/c2k}.npz`
160
174
  # --safetenors to use safe tensors, it's for easier binding in some languages
161
- python export.py --model /path/to/your/model.pth --p2k --fp16 --output /path/to/your/model.npz
175
+ python export.py --model /path/to/your/model.pth --p2k --output /path/to/your/model.npz
162
176
  ```
163
177
 
164
178
  > [!Note]
@@ -166,13 +180,10 @@ python export.py --model /path/to/your/model.pth --p2k --fp16 --output /path/to/
166
180
 
167
181
  ## License
168
182
 
169
- The code is released under WTFPL, you can do WTF you want with it.
170
-
171
- The dictionary should follow the [Wikimedia's license](https://dumps.wikimedia.org/legal.html) and the [JMdict / EDICT's Copyright](https://www.edrdg.org/) license.
172
-
173
- In short, as long as you provide the attribution, you can use it for both commercial and non-commercial purposes.
174
-
175
- The model weights are released under the same license as the dictionary.
183
+ - The code is released under WTFPL, you can do WTF you want with it.
184
+ - The dictionary follows the [Wikimedia's license](https://dumps.wikimedia.org/legal.html) and the [JMdict / EDICT's Copyright](https://www.edrdg.org/) license.
185
+ - In short, they both fall into CC-BY-SA.
186
+ - The model weights are trained using the dictionary. I am not a lawyer, whether the machine learning weights is considered as a derivative work is up to you.
176
187
 
177
188
  ## Credits
178
189
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "e2k"
3
- version = "0.2.2"
3
+ version = "0.3.0"
4
4
  description = "A tool for automatic English to Katakana conversion"
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Patchethium", email = "asguftuikh@gmail.com" }]
@@ -1,4 +1,4 @@
1
- from string import ascii_letters
1
+ from string import ascii_lowercase
2
2
 
3
3
 
4
4
  PAD_IDX = 0
@@ -165,7 +165,7 @@ en_phones = [
165
165
  "ZH",
166
166
  ]
167
167
 
168
- ascii_entries = ["<pad>", "<sos>", "<eos>"] + list(ascii_letters) + [" "]
168
+ ascii_entries = ["<pad>", "<sos>", "<eos>"] + list(ascii_lowercase) + [" ", "'"]
169
169
 
170
170
  kanas = ["<pad>", "<sos>", "<eos>"] + kanas
171
- en_phones = ["<pad>", "<sos>", "<eos>"] + en_phones + [" "]
171
+ en_phones = ["<pad>", "<sos>", "<eos>"] + en_phones + [" ", "'"]
@@ -314,7 +314,7 @@ if __name__ == "__main__":
314
314
  args = parser.parse_args()
315
315
  p2k = P2K()
316
316
  c2k = C2K()
317
- word = "gutenberg"
317
+ word = "vordhosbn"
318
318
  phonemes = g2p(word)
319
319
  print(word)
320
320
  print("P2K: ", p2k(phonemes))
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: e2k
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Summary: A tool for automatic English to Katakana conversion
5
5
  Author-email: Patchethium <asguftuikh@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -37,20 +37,31 @@ p2k = P2K()
37
37
 
38
38
  g2p = G2p()
39
39
 
40
- katakana = p2k(g2p("word"))
40
+ word = "word"
41
+
42
+ word = word.lower()
43
+
44
+ # you can check the accepted symbols using
45
+ in_table = c2k.in_table # `c2k` accepts lowercase characters, space and apostrophe
46
+ in_table = p2k.in_table # `p2k` accepts the phonemes from the CMUdict and space
47
+ # for output symbols
48
+ out_table = c2k.out_table
49
+ out_table = p2k.out_table
50
+
51
+ katakana = p2k(g2p(word))
41
52
 
42
53
  print(katakana) # "ワード"
43
54
 
44
- # character directly to katakana
55
+ # characters directly to katakana
45
56
  c2k = C2K()
46
57
 
47
- katakana = c2k("word")
58
+ katakana = c2k(word)
48
59
 
49
60
  print(katakana) # "ワード"
50
61
 
51
62
  # decode strategy
52
63
  # greedy by default, top_k and top_p are available
53
- # TODO: beam searh
64
+ # I tried implementing beam search but it barely differs from greedy
54
65
  c2k.set_decode_strategy("top_k", top_k=2) # low quality results, not recommended
55
66
  c2k.set_decode_strategy("top_p", top_p=0.6, t=0.8)
56
67
  # for further information, see
@@ -58,14 +69,17 @@ c2k.set_decode_strategy("top_p", top_p=0.6, t=0.8)
58
69
  print(katakana) # "ワード"
59
70
  ```
60
71
 
72
+ > [!WARNING]
73
+ > For any symbols not in the `in_table`, the model will ignore them and may produce unexpected results.
74
+
61
75
  ### Performance
62
76
 
63
77
  The BLEU score is calculated on a random subset with size of 10% of the dataset.
64
78
 
65
79
  | Model | BLEU Score ↑ |
66
80
  | ----- | ------------ |
67
- | P2K | 0.87 |
68
- | C2K | 0.91 |
81
+ | P2K | 0.89 |
82
+ | C2K | 0.92 |
69
83
 
70
84
  ## Dictionary
71
85
 
@@ -164,10 +178,10 @@ The model should be exported to `numpy` format for production use.
164
178
 
165
179
  ```bash
166
180
  # --p2k for phoneme to katakana, if not provided, it will be character to katakana
167
- # --fp16 for half precision, there's no reason not to use it
181
+ # --fp32 for double precision, by default we use fp16 to save space
168
182
  # --output to specify the output file, in this project it's `model-{p2k/c2k}.npz`
169
183
  # --safetenors to use safe tensors, it's for easier binding in some languages
170
- python export.py --model /path/to/your/model.pth --p2k --fp16 --output /path/to/your/model.npz
184
+ python export.py --model /path/to/your/model.pth --p2k --output /path/to/your/model.npz
171
185
  ```
172
186
 
173
187
  > [!Note]
@@ -175,13 +189,10 @@ python export.py --model /path/to/your/model.pth --p2k --fp16 --output /path/to/
175
189
 
176
190
  ## License
177
191
 
178
- The code is released under WTFPL, you can do WTF you want with it.
179
-
180
- The dictionary should follow the [Wikimedia's license](https://dumps.wikimedia.org/legal.html) and the [JMdict / EDICT's Copyright](https://www.edrdg.org/) license.
181
-
182
- In short, as long as you provide the attribution, you can use it for both commercial and non-commercial purposes.
183
-
184
- The model weights are released under the same license as the dictionary.
192
+ - The code is released under WTFPL, you can do WTF you want with it.
193
+ - The dictionary follows the [Wikimedia's license](https://dumps.wikimedia.org/legal.html) and the [JMdict / EDICT's Copyright](https://www.edrdg.org/) license.
194
+ - In short, they both fall into CC-BY-SA.
195
+ - The model weights are trained using the dictionary. I am not a lawyer, whether the machine learning weights is considered as a derivative work is up to you.
185
196
 
186
197
  ## Credits
187
198
 
Binary file
Binary file
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes