This repository has been archived by the owner on Dec 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fixja.py
79 lines (68 loc) · 1.79 KB
/
fixja.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- coding: utf-8 -*-
# -------------------------------------------
# nobo, No Borders
#
# fixja.py
# A collection of Japanese character issue fixing functions.
# -------------------------------------------
# @Author : Zhou Fang
# @Updated : 1/28/2019
# @Homepage: https://github.com/fang2hou/nobo
# -------------------------------------------
def convet_to_half_width(inputString: str) -> str:
fixDict = {
" ": " ",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"6": "6",
"7": "7",
"8": "8",
"9": "9",
"0": "0",
"(": "(",
")": ")",
}
finalString = inputString
for full, half in fixDict.items():
finalString = finalString.replace(full, half)
return finalString
def remove_newline(inputString):
finalString = inputString.replace("\n", "")
return finalString
def translate_weekday(string):
convert_dict = {
"月": "Monday",
"火": "Tuesday",
"水": "Wednesday",
"木": "Thursday",
"金": "Friday",
"月曜": "Monday",
"火曜": "Tuesday",
"水曜": "Wednesday",
"木曜": "Thursday",
"金曜": "Friday",
"月曜日": "Monday",
"火曜日": "Tuesday",
"水曜日": "Wednesday",
"木曜日": "Thursday",
"金曜日": "Friday",
}
for jp, en in convert_dict.items():
string = string.replace(jp, en)
return string
def remove_last_space(string):
remove_list = [
"\xa0", # Full-width Space used in Japanese
"\n",
"\t",
" "
]
if string in remove_list:
string = ""
else:
while string[-1:] in remove_list:
string = string[:-1]
return string