Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sooji #641

Closed
wants to merge 5 commits into from
Closed

Sooji #641

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ __pycache__/
/.coverage
/.project
/.pydevproject
/tai5_uan5_gian5_gi2_kang1_ku7.egg-info/
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@


class 阿拉伯數字():
一二三 = '一二三四五六七八九'
兩 = '兩'
細位 = ['', '十', '百', '千', ]
大位 = ['', '萬', '億', '兆', ]

def 是數字無(self, 數字):
return 數字.isdigit()
Expand Down Expand Up @@ -35,43 +31,6 @@ def 轉號碼(self, 空, 數字):
漢字.append(空一二三[int(數)])
return ''.join(漢字)

def 轉數量(self, 空, 數字):
if not self.是數量無(數字):
return 數字
空一二三 = 空 + self.一二三
漢字 = []
頭前有空號無 = False
大位有數字無 = False
for 所在 in range(len(數字)):
數值 = int(數字[所在])
數細位 = (len(數字) - 所在 - 1) % 4
數大位 = (len(數字) - 所在 - 1) // 4
if 數值 == 0:
頭前有空號無 = True
else:
大位有數字無 = True
if 頭前有空號無:
漢字.append(空一二三[0])
頭前有空號無 = False
if 數值 == 2:
if 數細位 == 1 or (所在 != 0 and 數細位 == 0): # 二十佮兩億零二萬
漢字.append(空一二三[2])
# elif 數細位==0 and 數大位==0:#二
# 漢字.append(空一二三[2])
else:
漢字.append(self.兩)
else:
漢字.append(空一二三[數值])
漢字.append(self.細位[數細位])
if 數細位 == 0 and 大位有數字無:
漢字.append(self.大位[數大位])
頭前有空號無 = False
大位有數字無 = False
結果 = ''.join(漢字)
if 結果.startswith('一十'):
return 結果[1:]
return 結果

def 轉閩南語數量無(self, 數量):
return self.轉閩南語數量(數量) != 數量

Expand Down Expand Up @@ -124,3 +83,46 @@ def 轉官話數量(self, 數量):
return 數量[:-2] + self.一二三[1]
return 數量[:-1]
return 數量


class 台語數字():
一二三 = '一二三四五六七八九'
兩 = '兩'
細位 = ['', '十', '百', '千', ]
大位 = ['', '萬', '億', '兆', ]

def 轉數量(self, 數字):
空一二三 = '空' + self.一二三
漢字 = []
頭前有空號無 = False
大位有數字無 = False
數字字串 = str(數字)
for 所在 in range(len(數字字串)):
數值 = int(數字字串[所在])
數細位 = (len(數字字串) - 所在 - 1) % 4
數大位 = (len(數字字串) - 所在 - 1) // 4
if 數值 == 0:
頭前有空號無 = True
else:
大位有數字無 = True
if 頭前有空號無:
漢字.append(空一二三[0])
頭前有空號無 = False
if 數值 == 2:
if 數細位 == 1 or (所在 != 0 and 數細位 == 0): # 二十佮兩億零二萬
漢字.append(空一二三[2])
# elif 數細位==0 and 數大位==0:#二
# 漢字.append(空一二三[2])
else:
漢字.append(self.兩)
else:
漢字.append(空一二三[數值])
漢字.append(self.細位[數細位])
if 數細位 == 0 and 大位有數字無:
漢字.append(self.大位[數大位])
頭前有空號無 = False
大位有數字無 = False
結果 = ''.join(漢字)
if 結果.startswith('一十'):
return 結果[1:]
return 結果
241 changes: 0 additions & 241 deletions 試驗/正規/Test阿拉伯數字單元試驗.py

This file was deleted.

Empty file removed 試驗/正規/__init__.py
Empty file.
Loading