feat: add korean postposition process
This commit is contained in:
parent
66e0abc25e
commit
6bd9e4e413
3 changed files with 38 additions and 11 deletions
|
@ -216,14 +216,14 @@ items = [
|
||||||
]
|
]
|
||||||
|
|
||||||
ands = [
|
ands = [
|
||||||
'에 빙의한',
|
[None, None, '에 빙의한'],
|
||||||
'에 들어가는',
|
[None, None, '에 들어가는'],
|
||||||
'에 묻힌',
|
[None, None, '에 묻힌'],
|
||||||
'을 연상시키는',
|
['을', '를', ' 연상시키는'],
|
||||||
' 같은',
|
[None, None, ' 같은'],
|
||||||
'로 가장한',
|
['으로', '로', ' 가장한'],
|
||||||
'에 올려진',
|
[None, None, '에 올려진'],
|
||||||
' 옆에 있는',
|
[None, None, ' 옆에 있는'],
|
||||||
];
|
];
|
||||||
|
|
||||||
from mipac.models import Note
|
from mipac.models import Note
|
||||||
|
@ -233,7 +233,7 @@ class AiTem(ModuleInterface):
|
||||||
self.name = "Ai-tem"
|
self.name = "Ai-tem"
|
||||||
self.regex_pattern = ".*Test_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.")
|
print("[Ai-tem] Ai-like item generator, Ai-tem V1 loaded.")
|
||||||
|
|
||||||
async def execute_module(self, ctx: Note):
|
async def execute_module(self, ctx: Note):
|
||||||
|
@ -241,7 +241,12 @@ class AiTem(ModuleInterface):
|
||||||
await ctx.api.action.reply(str(self._generate()), visibility="home")
|
await ctx.api.action.reply(str(self._generate()), visibility="home")
|
||||||
|
|
||||||
def _generate(self):
|
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):
|
def module_ready(self):
|
||||||
print("[Ai-tem] Module Ready.")
|
print("[Ai-tem] Module Ready.")
|
||||||
|
|
|
@ -47,7 +47,9 @@ class Amumal(ModuleInterface):
|
||||||
@tasks.loop(seconds=600.0)
|
@tasks.loop(seconds=600.0)
|
||||||
async def amumal_task(self):
|
async def amumal_task(self):
|
||||||
aitem = str(self.manager.require("Ai-tem").get_func("generate")())
|
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]):
|
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!")
|
print("[Amumal] Sent Amumal!")
|
||||||
|
|
||||||
|
|
20
modules/KJosa.py
Normal file
20
modules/KJosa.py
Normal 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.")
|
Loading…
Reference in a new issue