format code

pull/658/head
chenfeiyu 4 years ago
parent 7779f33e74
commit ae92fa7498

@ -1,7 +1,22 @@
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse import argparse
from text_processing import normalization from text_processing import normalization
parser = argparse.ArgumentParser(description="Normalize text in Chinese with some rules.") parser = argparse.ArgumentParser(
description="Normalize text in Chinese with some rules.")
parser.add_argument("input", type=str, help="the input sentences") parser.add_argument("input", type=str, help="the input sentences")
parser.add_argument("output", type=str, help="path to save the output file.") parser.add_argument("output", type=str, help="path to save the output file.")
args = parser.parse_args() args = parser.parse_args()

@ -1,5 +1,4 @@
export MAIN_ROOT=${PWD}/../../ export MAIN_ROOT=${PWD}/../../
export PATH=${MAIN_ROOT}:${MAIN_ROOT}/utils:${PATH} export PATH=${MAIN_ROOT}:${MAIN_ROOT}/utils:${PATH}
export LC_ALL=C export LC_ALL=C

@ -1,5 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source path.sh source path.sh
stage=-1 stage=-1

@ -2,6 +2,7 @@
`opencc <https://github.com/BYVoid/OpenCC>`_. `opencc <https://github.com/BYVoid/OpenCC>`_.
""" """
import opencc import opencc
_t2s_converter = opencc.OpenCC("t2s.json") _t2s_converter = opencc.OpenCC("t2s.json")

@ -1,6 +1,7 @@
import re import re
from .num import verbalize_cardinal, verbalize_digit, num2str, DIGITS from .num import verbalize_cardinal, verbalize_digit, num2str, DIGITS
def _time_num2str(num_string: str) -> str: def _time_num2str(num_string: str) -> str:
"""A special case for verbalizing number in time.""" """A special case for verbalizing number in time."""
result = num2str(num_string.lstrip('0')) result = num2str(num_string.lstrip('0'))

@ -2,6 +2,7 @@ import string
import re import re
from pypinyin.constants import SUPPORT_UCS4 from pypinyin.constants import SUPPORT_UCS4
# 全角半角转换 # 全角半角转换
# 英文字符全角 -> 半角映射表 (num: 52) # 英文字符全角 -> 半角映射表 (num: 52)
F2H_ASCII_LETTERS = { F2H_ASCII_LETTERS = {

@ -2,6 +2,7 @@
Rules to verbalize numbers into Chinese characters. Rules to verbalize numbers into Chinese characters.
https://zh.wikipedia.org/wiki/中文数字#現代中文 https://zh.wikipedia.org/wiki/中文数字#現代中文
""" """
import re import re
from typing import List from typing import List
from collections import OrderedDict from collections import OrderedDict

@ -1,6 +1,7 @@
import re import re
from .num import verbalize_digit from .num import verbalize_digit
# 规范化固话/手机号码 # 规范化固话/手机号码
# 手机 # 手机
# http://www.jihaoba.com/news/show/13680 # http://www.jihaoba.com/news/show/13680

@ -1,6 +1,7 @@
import re import re
from .num import num2str from .num import num2str
# 温度表达式,温度会影响负号的读法 # 温度表达式,温度会影响负号的读法
# -3°C 零下三度 # -3°C 零下三度
RE_TEMPERATURE = re.compile( RE_TEMPERATURE = re.compile(

@ -1,6 +1,7 @@
import re import re
from typing import List from typing import List
SENTENCE_SPLITOR = re.compile(r'([。!?][”’]?)') SENTENCE_SPLITOR = re.compile(r'([。!?][”’]?)')
def split(text: str) -> List[str]: def split(text: str) -> List[str]:

Loading…
Cancel
Save