summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Pignolet <matthieu@matthieu-dev.xyz>2024-06-06 14:11:49 +0400
committerMatthieu Pignolet <matthieu@matthieu-dev.xyz>2024-06-06 14:11:49 +0400
commitd46c5d9d7cd4398abe22d45fc2a47583658514ca (patch)
tree59fb68071f1c8e98385c68310cc4e7389c2bb83e
parentfbb787140e20b5c2aeca2f1cec1e8ba747ac1d3d (diff)
make weighted probabilities depending on node's children children count
-rw-r--r--autofeur_db/src/trie.rs2
-rw-r--r--discordjs/src/index.mjs3
2 files changed, 3 insertions, 2 deletions
diff --git a/autofeur_db/src/trie.rs b/autofeur_db/src/trie.rs
index b202a97..bbc2a93 100644
--- a/autofeur_db/src/trie.rs
+++ b/autofeur_db/src/trie.rs
@@ -112,7 +112,7 @@ impl<'a> Trie<'a> {
current_node
.child_nodes
.iter()
- .map(|(_, node)| node.child_count),
+ .map(|(_, node)| node.child_count / (length + 1)),
)
.expect("distribution creation should be valid");
diff --git a/discordjs/src/index.mjs b/discordjs/src/index.mjs
index 94499e5..c28c65d 100644
--- a/discordjs/src/index.mjs
+++ b/discordjs/src/index.mjs
@@ -1,5 +1,5 @@
// Require the necessary discord.js classes
-import { Client, GatewayIntentBits } from 'discord.js';
+import { Client, GatewayIntentBits, Message } from 'discord.js';
import { request } from "undici";
// Create a new client instance
@@ -42,6 +42,7 @@ client.on("messageCreate", async (message) => {
try {
// Get the completed word found by the db.
+
let response = await completeWord(cutWord(message.cleanContent));
// Ignore if there is no completion