This repository has been archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from sih4sing5hong5/輸出辭典模組化
輸出辭典模組化 fix #157
- Loading branch information
Showing
24 changed files
with
409 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/bin/bash | ||
echo "INSTALLED_APPS += ('匯入到臺灣言語資料庫',)" >> tai5uan5_gian5gi2_hok8bu7/settings.py | ||
echo "INSTALLED_APPS += ('匯入',)" >> tai5uan5_gian5gi2_hok8bu7/settings.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = '臺灣言語服務.初使設定.初使設定' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from 臺灣言語工具.基本物件.公用變數 import 無音 | ||
from 臺灣言語工具.基本物件.字 import 字 | ||
from 臺灣言語服務.漢語語音處理 import 漢語語音處理 | ||
|
||
|
||
class 辭典輸出: | ||
def __init__(self, 羅馬字, 選擇函式): | ||
self.羅馬字系統 = 羅馬字 | ||
self.輸出函式 = getattr(self, 選擇函式) | ||
|
||
def 拆做音素(self, 字物件): | ||
原聲, 韻, 調 = self._提出音值(字物件).音 | ||
聲 = 原聲 + '-' | ||
新韻類 = [] | ||
新調類 = set() | ||
for 一个音素 in 漢語語音處理.切漢語韻(韻): | ||
一个音素調 = 一个音素 + 調 | ||
新韻類.append((一个音素, 一个音素調)) | ||
新調類.add((調, 一个音素調)) | ||
return [聲], 新韻類, 新調類 | ||
|
||
def 拆做聲韻(self, 字物件): | ||
原聲, 韻, 調 = self._提出音值(字物件).音 | ||
聲 = 原聲 + '-' | ||
一个音素調 = 韻 + 調 | ||
return [聲], [(韻, 一个音素調)], {(調, 一个音素調)} | ||
|
||
def 拆做音節(self, 字物件): | ||
原聲, 韻, 調 = self._提出音值(字物件).音 | ||
一个音素調 = 原聲 + 韻 + 調 | ||
return [], [(原聲 + 韻, 一个音素調)], {(調, 一个音素調)} | ||
|
||
def _提出音值(self, 字物件): | ||
if 字物件.音 != 無音: | ||
檢查字物件 = 字物件 | ||
else: | ||
檢查字物件 = 字(字物件.型, 字物件.型) | ||
if not 檢查字物件.音標敢著(self.羅馬字系統): | ||
raise ValueError('音標無合法') | ||
return 檢查字物件.轉音(self.羅馬字系統, '音值') | ||
|
||
def 漢字聲韻(self, 音節): | ||
音標物件 = self.羅馬字系統(音節) | ||
return 音標物件.聲 + 音標物件.韻 |
Oops, something went wrong.