From 28ccfbfc51068a663a80764e14074df5edf2b5ba Mon Sep 17 00:00:00 2001
From: kongdeqiang <kongdeqiang960204@163.com>
Date: 星期五, 13 三月 2026 17:41:41 +0800
Subject: [PATCH] 提交
---
fun_text_processing/inverse_text_normalization/fr/verbalizers/decimal.py | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/fun_text_processing/inverse_text_normalization/fr/verbalizers/decimal.py b/fun_text_processing/inverse_text_normalization/fr/verbalizers/decimal.py
index daa532e..fadb7da 100644
--- a/fun_text_processing/inverse_text_normalization/fr/verbalizers/decimal.py
+++ b/fun_text_processing/inverse_text_normalization/fr/verbalizers/decimal.py
@@ -1,4 +1,3 @@
-
import pynini
from fun_text_processing.inverse_text_normalization.fr.graph_utils import (
DAMO_DIGIT,
@@ -12,8 +11,8 @@
class NumberParser(GraphFst):
"""
- Finite state transducer for parsing strings of digis. Breaks up digit strings into groups of three for
- strings of digits of four or more (inclusive). Groupings are separated by non-breaking space.
+ Finite state transducer for parsing strings of digis. Breaks up digit strings into groups of three for
+ strings of digits of four or more (inclusive). Groupings are separated by non-breaking space.
e.g. '1000' -> '1 000'
e.g. '1000,33333' -> '1 000,333 33
"""
@@ -32,11 +31,12 @@
super().__init__(name="decimal", kind="verbalize")
# Need parser to group digits by threes
- exactly_three_digits = DAMO_DIGIT ** 3
+ exactly_three_digits = DAMO_DIGIT**3
at_most_three_digits = pynini.closure(DAMO_DIGIT, 1, 3)
space_every_three_integer = (
- at_most_three_digits + (pynutil.insert(DAMO_NON_BREAKING_SPACE) + exactly_three_digits).closure()
+ at_most_three_digits
+ + (pynutil.insert(DAMO_NON_BREAKING_SPACE) + exactly_three_digits).closure()
)
space_every_three_decimal = (
pynini.accep(",")
@@ -46,13 +46,13 @@
group_by_threes = space_every_three_integer | space_every_three_decimal
self.group_by_threes = group_by_threes
- optional_sign = pynini.closure(pynini.cross("negative: \"true\"", "-") + delete_space, 0, 1)
+ optional_sign = pynini.closure(pynini.cross('negative: "true"', "-") + delete_space, 0, 1)
integer = (
pynutil.delete("integer_part:")
+ delete_space
- + pynutil.delete("\"")
+ + pynutil.delete('"')
+ pynini.closure(DAMO_NOT_QUOTE, 1)
- + pynutil.delete("\"")
+ + pynutil.delete('"')
)
integer = integer @ group_by_threes
optional_integer = pynini.closure(integer + delete_space, 0, 1)
@@ -60,18 +60,18 @@
pynutil.insert(",")
+ pynutil.delete("fractional_part:")
+ delete_space
- + pynutil.delete("\"")
+ + pynutil.delete('"')
+ pynini.closure(DAMO_NOT_QUOTE, 1)
- + pynutil.delete("\"")
+ + pynutil.delete('"')
)
fractional = fractional @ group_by_threes
optional_fractional = pynini.closure(fractional + delete_space, 0, 1)
quantity = (
pynutil.delete("quantity:")
+ delete_space
- + pynutil.delete("\"")
+ + pynutil.delete('"')
+ pynini.closure(DAMO_NOT_QUOTE, 1)
- + pynutil.delete("\"")
+ + pynutil.delete('"')
)
optional_quantity = pynini.closure(pynutil.insert(" ") + quantity + delete_space, 0, 1)
graph = (optional_integer + optional_fractional + optional_quantity).optimize()
--
Gitblit v1.9.1