正则表达式翻译asr9000

本文档提供了ASR9K路由器中特定正则表达式的替换步骤,涉及bridge-domain、split-horizon、xconnect、service instance和interface的配置更新,以优化网络设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

正则表达式-ASR9K
bridge-domain ^([0-9]+^) split-horizon
替换
 bridge group ^1
 bridge-domain ^1
  interface Bundle-Ether104.^1
  split-horizon group
xconnect ^([0-9.]+^) ^([0-9]+^) encapsulation mpls
替换
p2p **
  interface Bundle-Ether104.2591
  neighbor ipv4 ^1 pw-id ^2
  pw-class l2vpn

 service instance ^([0-9]+^) ethernet
 description([0-9a-zA-Z-. ]+^)
 encapsulation dot1q ^([0-9]+^)
 rewrite ingress tag pop 1 symmetric
 xconnect ^([0-9.]+^) ^([0-9]+^) encapsulation mpls

-------------------------------------------------------------------
interface Bundle-Ether106.^([0-9]+^)
 description^([0-9a-zA-Z-. ]+^)
 encapsulation dot1q ^([0-9]+^)
 xconnect ^([0-9.]+^) ^([0-9]+^) encapsulation mpls
替换
interface Bundle-Ether106.^1 l2transport
 description^2
 encapsulation dot1q ^3
 p2p ^1
 interface Bundle-Ether106.^1
  neighbor ipv4 ^4 pw-id ^5
  pw-class l2vpn
-----------------------------------------------------------
 service instance ^([0-9]+^) ethernet
 description^([0-9a-zA-Z-. ]+^)
 encapsulation dot1q ^([0-9]+^)
 rewrite ingress tag pop 1 symmetric
 bridge-domain ^([0-9]+^) split-horizon
替换
 service instance ^([0-9]+^) ethernet
 description^([0-9a-zA-Z-. ]+^)
 encapsulation dot1q ^([0-9]+^)
 rewrite ingress tag pop 1 symmetric
 bridge-domain ^([0-9]+^) split-horizon
-------------------------------------------------------
interface GigabitEthernet0/0/0/^([0-9. ]+^)
 encapsulation dot1Q ^([0-9]+^)
 xconnect ^([0-9.]+^) ^([0-9]+^) encapsulation mpls
更换
interface GigabitEthernet0/0/0/^1 l2transport
 encapsulation dot1q ^2
 p2p ^2
 interface GigabitEthernet0/0/0/^1
  neighbor ipv4 ^3 pw-id ^4
  pw-class l2vpn

class LLMWrapper: def __init__(self, model_path): self.tokenizer = AutoTokenizer.from_pretrained(model_path) self.model = AutoModelForCausalLM.from_pretrained( model_path, device_map="auto", quantization_config=BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_use_double_quant=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.float16 ), torch_dtype=torch.float16, trust_remote_code=True ) logging.info("模型加载完成") def summarize(self, text): """生成30字以内摘要""" try: prompt = f"用中文一句话总结内容,50字内:{text[:500]}" inputs = self.tokenizer(prompt, return_tensors="pt").to(self.model.device) outputs = self.model.generate( **inputs, max_new_tokens=30, temperature=0.3, repetition_penalty=1.2 ) summary = self.tokenizer.decode(outputs[0], skip_special_tokens=True) return re.sub(r'[^\u4e00-\u9fff。,!?]', '', summary)[:30] except Exception as e: logging.error(f"摘要生成异常: {str(e)}") return "(生成失败)" def process_file(filepath, asr_pipeline, llm): """处理单个音频文件""" file_info = { "文件名": filepath.name, "时长": 0, "文本内容": "", "内容摘要": "", "处理状态": "待处理", "耗时": 0 } try: start_time = time.time() # 文件格式验证 if filepath.suffix.lower() != '.wav': raise ValueError("仅支持.wav格式文件") # 获取音频时长 with sf.SoundFile(str(filepath)) as f: file_info["时长"] = round(f.frames / f.samplerate, 2) # 语音识别 asr_result = asr_pipeline.generate(input=str(filepath)) text = asr_result[0]["text"] if asr_result else "" file_info["文本内容"] = text # 生成摘要 if text: file_info["内容摘要"] = llm.summarize(text) file_info.update({ "处理状态": "成功", "耗时": round(time.time() - start_time, 1) }) except Exception as e: file_info.update({ "处理状态": f"失败: {str(e)}", "耗时": round(time.time() - start_time, 1) }) return file_info以上是核心代码 生成文字里,这个内容摘要偏差太大了,存在较大错漏,怎么调整?即没有一句话总结内容,又将提问也加进了摘要里 内容摘要 用中文一句话总结内容,字内论文卡在文献综述部分怎么办试试先做 用中文一句话总结内容,字内这个智能眼镜能实时翻译外语对还能叠 用中文一句话总结内容,字内听说雨衣甘蓝要浊水去草酸冷榨橙汁反
最新发布
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值