From 790e4b49e4394565aba3a76c10ed6b90ffb37c9b Mon Sep 17 00:00:00 2001 From: Kyomotoi <0w0@imki.moe> Date: Fri, 4 Nov 2022 10:17:46 +0800 Subject: =?UTF-8?q?=F0=9F=8E=A8=20=E8=B7=9F=E9=9A=8F=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E8=AE=BE=E6=96=BD=E5=8F=98=E5=8C=96,=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ATRI/plugins/util/data_source.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ATRI/plugins/util') diff --git a/ATRI/plugins/util/data_source.py b/ATRI/plugins/util/data_source.py index 5245518..68edc82 100644 --- a/ATRI/plugins/util/data_source.py +++ b/ATRI/plugins/util/data_source.py @@ -1,7 +1,7 @@ import re from math import floor import jieba.posseg as pseg -from typing import Union, Optional +from typing import Union from random import random, choice, randint @@ -179,7 +179,7 @@ class Yinglish: def __init__(self, context: str): self.context = context - def _to_ying(x, y, ying) -> str: + def _to_ying(self, x: str, y: str, ying: float) -> str: if random() > ying: return x if x in [",", "。"]: @@ -202,5 +202,5 @@ class Yinglish: x = "〇" * len(x) return str(choice([f"...{x}", f"....{x}", f".....{x}", f"......{x}"])) - def deal(self, ying: Optional[float] = 0.5) -> str: + def deal(self, ying: float = 0.5) -> str: return "".join([self._to_ying(x, y, ying) for x, y in pseg.cut(self.context)]) -- cgit v1.2.3