Improve similarity detection
All checks were successful
Build and Publish college-bot-v2 / build_and_publish (push) Successful in 2m1s
All checks were successful
Build and Publish college-bot-v2 / build_and_publish (push) Successful in 2m1s
This commit is contained in:
parent
8f5a9d741a
commit
08f167e294
3 changed files with 21 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
jishaku~=2.5
|
||||||
wheel>=0.42
|
wheel>=0.42
|
||||||
setuptools>=69
|
setuptools>=69
|
||||||
yt-dlp @ https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz
|
yt-dlp @ https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz
|
||||||
|
|
|
@ -1116,6 +1116,7 @@ class Ollama(commands.Cog):
|
||||||
await msg.edit(embed=embed)
|
await msg.edit(embed=embed)
|
||||||
last_edit = time.time()
|
last_edit = time.time()
|
||||||
|
|
||||||
|
similar = {}
|
||||||
for truth in truths:
|
for truth in truths:
|
||||||
_ratio = fuzz.ratio(truth.content, embed.description)
|
_ratio = fuzz.ratio(truth.content, embed.description)
|
||||||
if truth.content == embed.description:
|
if truth.content == embed.description:
|
||||||
|
@ -1124,10 +1125,26 @@ class Ollama(commands.Cog):
|
||||||
value="This truth was already truthed. Shit AI."
|
value="This truth was already truthed. Shit AI."
|
||||||
)
|
)
|
||||||
elif _ratio >= 70:
|
elif _ratio >= 70:
|
||||||
|
similar[truth.id] = _ratio
|
||||||
|
|
||||||
|
if similar:
|
||||||
|
if len(similar) > 1:
|
||||||
|
lns = []
|
||||||
|
for truth_id, _ratio in similar.items():
|
||||||
|
lns.append(f"* `{truth_id}`: {_ratio:.2f}%")
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Likely repeated truth",
|
name="Possibly repeated truth",
|
||||||
value=f"Is a {_ratio:.2f}% match to truth {truth.id!r}."
|
value="This truth was similar to the following existing ones:\n" + "\n".join(lns),
|
||||||
|
inline=False
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
truth_id = tuple(similar)[0]
|
||||||
|
_ratio = similar[truth_id]
|
||||||
|
embed.add_field(
|
||||||
|
name="Possibly repeated truth",
|
||||||
|
value=f"This truth was {_ratio:.2f}% similar to `{truth_id}`."
|
||||||
|
)
|
||||||
|
|
||||||
embed.set_footer(
|
embed.set_footer(
|
||||||
text="Finished generating truth based off of {:,} messages, using server {!r} | {!s}".format(
|
text="Finished generating truth based off of {:,} messages, using server {!r} | {!s}".format(
|
||||||
len(messages) - 2,
|
len(messages) - 2,
|
||||||
|
|
|
@ -162,7 +162,7 @@ bot = Client(
|
||||||
intents=discord.Intents.all(),
|
intents=discord.Intents.all(),
|
||||||
)
|
)
|
||||||
|
|
||||||
for module in CONFIG["jimmy"].get("modules", ["cogs/*.py"]):
|
for module in ["jishaku", *CONFIG["jimmy"].get("modules", ["cogs/*.py"])]:
|
||||||
try:
|
try:
|
||||||
bot.load_extension(module)
|
bot.load_extension(module)
|
||||||
except (discord.ExtensionNotFound, ModuleNotFoundError):
|
except (discord.ExtensionNotFound, ModuleNotFoundError):
|
||||||
|
|
Loading…
Reference in a new issue