aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/example/plugins/tf
diff options
context:
space:
mode:
Diffstat (limited to 'example/plugins/tf')
-rw-r--r--example/plugins/tf/__init__.py52
-rw-r--r--example/plugins/tf/config.py0
2 files changed, 52 insertions, 0 deletions
diff --git a/example/plugins/tf/__init__.py b/example/plugins/tf/__init__.py
new file mode 100644
index 0000000..ce78d97
--- /dev/null
+++ b/example/plugins/tf/__init__.py
@@ -0,0 +1,52 @@
+
+from iamai import Plugin
+from iamai.log import logger as _logger
+from HydroRoll.models.cos_sim import cosSim
+import jieba
+
+logger = _logger
+
+
+texts = [
+ "你好 HydroRoll",
+ "你好 水系",
+ "hi 水系",
+ "hi HydroRoll",
+ "hello 水系",
+ "hello HydroRoll",
+ "hola 水系",
+ "hola HydroRoll",
+]
+
+cos_Sim = cosSim(texts)
+logger.info(f"{cos_Sim.calcuSim('你好')}")
+
+cos_Sim.save('cos.h5')
+
+model = cosSim.load('cos.h5')
+
+logger.info(f"{model}")
+
+# class Sim(Plugin):
+# async def handle(self) -> None:
+# try:
+
+# txt_list = eval(self.event.message.get_plain_text()[5:])
+# if len(txt_list) == 1:
+# await self.event.reply(f"{cos_Sim.CalcuSim(txt_list)}")
+# elif len(txt_list) == 2:
+# corpuss = [" ".join(jieba.cut(text))
+# for text in eval(self.event.message.get_plain_text()[5:])]
+# await self.event.reply(str(corpuss))
+# vocabulary = cos_Sim.getVocabulary(corpuss)
+# v = cos_Sim.getVectors(corpuss, vocabulary=vocabulary)
+# await self.event.reply(f"weight\n=========\n{v}")
+# await self.event.reply(f"相似度\n=========\n{cos_Sim.cos_sim(v[0], v[1])}")
+# except Exception as e:
+# await self.event.reply(f"{e!r}")
+
+# async def rule(self) -> bool:
+# return self.event.type == "message" and self.event.message.startswith(".cos")
+
+
+
diff --git a/example/plugins/tf/config.py b/example/plugins/tf/config.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/example/plugins/tf/config.py