Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
實作改好 #234
Browse files Browse the repository at this point in the history
  • Loading branch information
sih4sing5hong5 committed Apr 3, 2018
1 parent 474559d commit 1ac7f88
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions 臺灣言語服務/Kaldi語料處理.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-

from 臺灣言語工具.基本物件.公用變數 import 無音
from 臺灣言語工具.解析整理.拆文分析器 import 拆文分析器
from 臺灣言語服務.Kaldi語料匯出 import Kaldi語料匯出
from 臺灣言語工具.基本物件.公用變數 import 分型音符號
import re
from 臺灣言語工具.解析整理.解析錯誤 import 解析錯誤
from 臺灣言語服務.Kaldi語料匯出 import Kaldi語料匯出
from 臺灣言語服務.models import 訓練過渡格式
from 臺灣言語工具.基本物件.公用變數 import 無音
import re


class Kaldi語料處理():
Expand All @@ -33,8 +32,8 @@ def 轉fst格式(cls, 辭典輸出物件, 音陣列):
= set()
for 音節 in 音陣列:
.add(
'0\t0\t{2}{1}{2}\t{2}{1}{2}'.format(
音節, 分型音符號, 辭典輸出物件.漢字聲韻(音節)
'0\t0\t{1}\t{1}'.format(
音節, 辭典輸出物件.漢字聲韻(音節)
)
)
資料 = sorted()
Expand All @@ -47,7 +46,7 @@ def 轉辭典檔(cls, 辭典輸出物件, 音陣列):
for 音節 in sorted(音陣列):
辭典格式, *_新聲學類 = Kaldi語料匯出.音節轉辭典格式(
拆文分析器.對齊字物件(音節, 音節), 辭典輸出物件,
'{1}{0}{1}'.format(分型音符號, 辭典輸出物件.漢字聲韻(音節))
辭典輸出物件.漢字聲韻(音節)
)
資料.add(辭典格式)
return sorted(資料)
Expand All @@ -67,9 +66,7 @@ def 轉音節text格式(cls, 音標系統, 語句陣列):
= 字物件.
音標物件 = 音標系統()
if 音標物件.音標:
音節逝.append('{2}{1}{2}'.format(
音標物件.音標, 分型音符號, 音標物件. + 音標物件.
))
音節逝.append(音標物件. + 音標物件.)
結果.append(' '.join(音節逝))
return 結果

Expand Down

0 comments on commit 1ac7f88

Please sign in to comment.