for n in books_infos_next:
时间: 2024-05-24 09:11:26 浏览: 25
I'm sorry, as an AI language model, I don't have enough context to understand what you are trying to accomplish with this line of code. Can you please provide more information or code context?
相关问题
def __init__(self, json_dir, n_src=2, sample_rate=8000, segment=4.0): super().__init__() # Task setting self.json_dir = json_dir self.sample_rate = sample_rate if segment is None: self.seg_len = None else: self.seg_len = int(segment * sample_rate) self.n_src = n_src self.like_test = self.seg_len is None # Load json files mix_json = os.path.join(json_dir, "mix.json") sources_json = [ os.path.join(json_dir, source + ".json") for source in [f"s{n+1}" for n in range(n_src)] ] with open(mix_json, "r") as f: mix_infos = json.load(f) sources_infos = [] for src_json in sources_json: with open(src_json, "r") as f: sources_infos.append(json.load(f)) # Filter out short utterances only when segment is specified orig_len = len(mix_infos) drop_utt, drop_len = 0, 0 if not self.like_test: for i in range(len(mix_infos) - 1, -1, -1): # Go backward if mix_infos[i][1] < self.seg_len: drop_utt += 1 drop_len += mix_infos[i][1] del mix_infos[i] for src_inf in sources_infos: del src_inf[i] print( "Drop {} utts({:.2f} h) from {} (shorter than {} samples)".format( drop_utt, drop_len / sample_rate / 36000, orig_len, self.seg_len ) ) self.mix = mix_infos self.sources = sources_infos
这是一个 Python 类的初始化函数,看起来是用于处理音频混合数据和其源数据的。具体来说,它的输入参数包括一个 JSON 目录、音频源的数量、采样率和段长度等。它会从指定的 JSON 文件中读取混合音频和其源音频的信息,并对其中长度太短的音频进行过滤。最终,该函数会将处理好的音频混合数据和其源数据存储在该类的 mix 和 sources 属性中。
for index, (invoice_info, details_infos) in enumerate(zip(details, invoice_details)): for line_detail in details_infos: line_item_name = ignore_special_symbols(try2get(line_detail, item_name_keys)) line_item_price = line_detail['单价'] if line_item_name in item_name_map.keys(): item_name_map[line_item_name][0].append(xor_float_r2(line_item_price)) item_name_map[line_item_name][1].append(index) else: if not line_item_name: continue item_name_map.update({line_item_name: ([xor_float_r2(line_item_price)], [index])})将这段代码简化
这段代码的作用是将发票信息中的每个条目的名称和价格存储到一个字典中,字典的键是名称,值是一个元组列表,元组中包含价格和该条目在发票信息中的索引。
代码简化后如下:
```
for invoice_info, details_infos in zip(details, invoice_details):
for line_detail in details_infos:
line_item_name = ignore_special_symbols(try2get(line_detail, item_name_keys))
line_item_price = line_detail['单价']
if not line_item_name:
continue
if line_item_name in item_name_map:
item_name_map[line_item_name][0].append(xor_float_r2(line_item_price))
item_name_map[line_item_name][1].append(index)
else:
item_name_map[line_item_name] = ([xor_float_r2(line_item_price)], [index])
```
阅读全文