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)

---
 runtime/tools/fst/generate_lexicon.py |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/runtime/tools/fst/generate_lexicon.py b/runtime/tools/fst/generate_lexicon.py
index a5a47ec..f8c7443 100755
--- a/runtime/tools/fst/generate_lexicon.py
+++ b/runtime/tools/fst/generate_lexicon.py
@@ -8,18 +8,19 @@
 # sys.argv[3]: lexicon file for corpus.dict
 
 lex_dict = {}
-with open(sys.argv[2], 'r', encoding='utf8') as fin:
+with open(sys.argv[2], "r", encoding="utf8") as fin:
     for line in fin:
-        words = line.strip().split('\t')
+        words = line.strip().split("\t")
         if len(words) != 2:
             continue
         lex_dict[words[0]] = words[1]
 
-with open(sys.argv[1], 'r', encoding='utf8') as fin, \
-        open(sys.argv[3], 'w', encoding='utf8') as fout:
+with open(sys.argv[1], "r", encoding="utf8") as fin, open(
+    sys.argv[3], "w", encoding="utf8"
+) as fout:
     for line in fin:
         word = line.strip()
-        if word == '<s>' or word == '</s>':
+        if word == "<s>" or word == "</s>":
             continue
         word_lex = ""
         if word in lex_dict:
@@ -29,7 +30,6 @@
                 if word[i] in lex_dict:
                     word_lex += " " + lex_dict[word[i]]
                 else:
-                    word_lex += " <unk>" 
-            
-        fout.write('{}\t{}\n'.format(word, word_lex.strip()))
+                    word_lex += " <unk>"
 
+        fout.write("{}\t{}\n".format(word, word_lex.strip()))

--
Gitblit v1.9.1