feat: add korean postposition process

This commit is contained in:
Soumt Nam 2023-09-12 21:44:28 +09:00
parent 66e0abc25e
commit 6bd9e4e413
3 changed files with 38 additions and 11 deletions

View file

@ -216,14 +216,14 @@ items = [
]
ands = [
'에 빙의한',
'에 들어가는',
'에 묻힌',
' 연상시키는',
' 같은',
'로 가장한',
'에 올려진',
' 옆에 있는',
[None, None, '에 빙의한'],
[None, None, '에 들어가는'],
[None, None, '에 묻힌'],
['', '', ' 연상시키는'],
[None, None, ' 같은'],
['으로', '', ' 가장한'],
[None, None, '에 올려진'],
[None, None, ' 옆에 있는'],
];
from mipac.models import Note
@ -233,7 +233,7 @@ class AiTem(ModuleInterface):
self.name = "Ai-tem"
self.regex_pattern = ".*Test_AI-tem"
self.funcs["generate"] = self._generate()
self.funcs["generate"] = self._generate
print("[Ai-tem] Ai-like item generator, Ai-tem V1 loaded.")
async def execute_module(self, ctx: Note):
@ -241,7 +241,12 @@ class AiTem(ModuleInterface):
await ctx.api.action.reply(str(self._generate()), visibility="home")
def _generate(self):
return random.choice(itemPrefixes) + ' ' + random.choice(items) + ((random.choice(ands) + ' ' + random.choice(itemPrefixes) + ' ' + random.choice(items)) if random.choice([True, False]) else "")
item1_sel = random.choice(items)
con_sel = random.choice(ands)
item1_comp = self.manager.require("K-Josa").get_func("process_josa")(item1_sel, con_sel[0], con_sel[1]) + con_sel[2]
print(item1_sel, item1_comp)
return random.choice(itemPrefixes) + ' ' + ((item1_comp + ' ' + random.choice(itemPrefixes) + ' ' + random.choice(items)) if random.choice([True, False]) else item1_sel)
def module_ready(self):
print("[Ai-tem] Module Ready.")

View file

@ -47,7 +47,9 @@ class Amumal(ModuleInterface):
@tasks.loop(seconds=600.0)
async def amumal_task(self):
aitem = str(self.manager.require("Ai-tem").get_func("generate")())
kjosa = self.manager.require("K-Josa").get_func("process_josa")
if random.choice([True, False]):
await self.manager.bot.client.note.action.send(random.choice(Amumals["notes"] + [aitem + "이 가지고 싶어요...", "오늘 산책 중에 " + aitem + "을 봤어요!"]), visibility="home")
await self.manager.bot.client.note.action.send(random.choice(Amumals["notes"] + [kjosa(aitem, "", "") + " 가지고 싶어요...", "오늘 산책 중에 " + kjosa(aitem, "", "") + " 봤어요!"]), visibility="home")
print("[Amumal] Sent Amumal!")

20
modules/KJosa.py Normal file
View file

@ -0,0 +1,20 @@
from module_interface import ModuleInterface
from mipac.models import Note
class KJosa(ModuleInterface):
def __init__(self):
super().__init__()
self.name = "K-Josa"
self.regex_pattern = None
self.funcs["process_josa"] = self._process
print("[K-Josa] Korean postposition processor, K-Josa V1 loaded.")
async def execute_module(self, ctx: Note):
pass
def _process(self, w, t, f):
return (w + ((t if (ord(w[-1])- 44032 % 28 == 0) else f ) if (44032 <= ord(w[-1]) <= 55203) else f"{t}({f})")) if t and f else w
def module_ready(self):
print("[K-josa] Module Ready.")