From 6e69d784e4814c3dbe35e8f70c6cf4b920c8b20b Mon Sep 17 00:00:00 2001
From: 天地 <tiandiweizun@gmail.com>
Date: 星期三, 19 三月 2025 23:10:13 +0800
Subject: [PATCH] 1. bug fix:list(mean)和list(var),由于mean和var是numpy,导致写入到文件的格式错误,参考上面的话,大概率是list(mean.tolist()),其实外层list没有必要 (#2437)
---
fun_text_processing/text_normalization/zh/verbalizers/date.py | 50 ++++++++++++++++++++------------------------------
1 files changed, 20 insertions(+), 30 deletions(-)
diff --git a/fun_text_processing/text_normalization/zh/verbalizers/date.py b/fun_text_processing/text_normalization/zh/verbalizers/date.py
index 367c8d2..cf0e604 100644
--- a/fun_text_processing/text_normalization/zh/verbalizers/date.py
+++ b/fun_text_processing/text_normalization/zh/verbalizers/date.py
@@ -1,32 +1,22 @@
-# Copyright NeMo (https://github.com/NVIDIA/NeMo). 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 pynini
-from fun_text_processing.text_normalization.zh.graph_utils import FUN_NOT_QUOTE, GraphFst, delete_space
+from fun_text_processing.text_normalization.zh.graph_utils import (
+ FUN_NOT_QUOTE,
+ GraphFst,
+ delete_space,
+)
from fun_text_processing.text_normalization.zh.utils import UNIT_1e01, get_abs_path
from pynini.lib import pynutil
class Date(GraphFst):
- '''
- tokens { date { year: "2002" month: "01" day: "28"} } -> 浜岄浂闆朵簩骞翠竴鏈堜簩鍗佸叓鏃�
- tokens { date { year: "2002" } } -> 浜岄浂闆跺叓骞�
- '''
+ """
+ tokens { date { year: "2002" month: "01" day: "28"} } -> 浜岄浂闆朵簩骞翠竴鏈堜簩鍗佸叓鏃�
+ tokens { date { year: "2002" } } -> 浜岄浂闆跺叓骞�
+ """
def __init__(self, deterministic: bool = True, lm: bool = False):
super().__init__(name="date", kind="verbalize", deterministic=deterministic)
- date_type0 = pynutil.delete('year: \"') + pynini.closure(FUN_NOT_QUOTE) + pynutil.delete('\"')
+ date_type0 = pynutil.delete('year: "') + pynini.closure(FUN_NOT_QUOTE) + pynutil.delete('"')
graph_digit = pynini.string_file(get_abs_path("data/number/digit.tsv"))
graph_teen = pynini.string_file(get_abs_path("data/number/digit_teen.tsv"))
graph_zero = pynini.string_file(get_abs_path("data/number/zero.tsv"))
@@ -38,32 +28,32 @@
)
date_type1 = (
- pynutil.delete("year: \"")
+ pynutil.delete('year: "')
+ graph_year
+ pynutil.insert("骞�")
- + pynutil.delete("\"")
+ + pynutil.delete('"')
+ delete_space
- + pynutil.delete("month: \"")
+ + pynutil.delete('month: "')
+ graph_2_digit_date
+ pynutil.insert("鏈�")
- + pynutil.delete("\"")
+ + pynutil.delete('"')
+ delete_space
- + pynutil.delete("day: \"")
+ + pynutil.delete('day: "')
+ graph_2_digit_date
+ pynutil.insert("鏃�")
- + pynutil.delete("\"")
+ + pynutil.delete('"')
)
date_type2 = (
- pynutil.delete("year: \"")
+ pynutil.delete('year: "')
+ graph_year
+ pynutil.insert("骞�")
- + pynutil.delete("\"")
+ + pynutil.delete('"')
+ delete_space
- + pynutil.delete("month: \"")
+ + pynutil.delete('month: "')
+ graph_2_digit_date
+ pynutil.insert("鏈�")
- + pynutil.delete("\"")
+ + pynutil.delete('"')
)
graph = date_type0 | date_type1 | date_type2
--
Gitblit v1.9.1