MCPcopy Index your code
hub / github.com/modelscope/FunASR / abbr_dispose

Function abbr_dispose

funasr/utils/postprocess_utils.py:71–162  ·  view source on GitHub ↗

Abbr dispose. Args: words: TODO. time_stamp: TODO.

(words: List[Any], time_stamp: List[List] = None)

Source from the content-addressed store, hash-verified

69
70# def abbr_dispose(words: List[Any]) -> List[Any]:
71def abbr_dispose(words: List[Any], time_stamp: List[List] = None) -> List[Any]:
72 """Abbr dispose.
73
74 Args:
75 words: TODO.
76 time_stamp: TODO.
77 """
78 words_size = len(words)
79 word_lists = []
80 abbr_begin = []
81 abbr_end = []
82 last_num = -1
83 ts_lists = []
84 ts_nums = []
85 ts_index = 0
86 for num in range(words_size):
87 if num <= last_num:
88 continue
89
90 if len(words[num]) == 1 and words[num].encode("utf-8").isalpha():
91 if (
92 num + 1 < words_size
93 and words[num + 1] == " "
94 and num + 2 < words_size
95 and len(words[num + 2]) == 1
96 and words[num + 2].encode("utf-8").isalpha()
97 ):
98 # found the begin of abbr
99 abbr_begin.append(num)
100 num += 2
101 abbr_end.append(num)
102 # to find the end of abbr
103 while True:
104 num += 1
105 if num < words_size and words[num] == " ":
106 num += 1
107 if (
108 num < words_size
109 and len(words[num]) == 1
110 and words[num].encode("utf-8").isalpha()
111 ):
112 abbr_end.pop()
113 abbr_end.append(num)
114 last_num = num
115 else:
116 break
117 else:
118 break
119
120 for num in range(words_size):
121 if words[num] == " ":
122 ts_nums.append(ts_index)
123 else:
124 ts_nums.append(ts_index)
125 ts_index += 1
126 last_num = -1
127 for num in range(words_size):
128 if num <= last_num:

Callers 1

sentence_postprocessFunction · 0.70

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…