Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

Commit 8abae3d

Browse files
author
Cipher
committed
Mathematical correction
1 parent a26edf4 commit 8abae3d

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

Janex.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,26 @@ def responsecompare(input_string, intents_file_path, intent_class):
7070

7171
for InputWord in BagOfWords:
7272
for OutputWord in WordList:
73-
# print(InputWord)
74-
# print(OutputWord)
7573
if InputWord == OutputWord:
76-
Similarity = Similarity + 1
74+
Similarity += 1
7775
print("Match found!")
7876

79-
if Similarity > MaxSimilarity:
80-
OutofHundred = len(input_string)
81-
Hundred = len(BagOfWords + WordList)
77+
OutofHundred = len(BagOfWords) # Total number of words in the input
78+
Hundred = len(BagOfWords + WordList) # Total number of words in both input and pattern
8279

83-
SimilarityPercentage = OutofHundred/Hundred*100
80+
SimilarityPercentage = (Similarity / Hundred) * 100 # Corrected calculation
8481

85-
print(f"Similarity: {SimilarityPercentage:.2f}%")
82+
print(f"Similarity: {SimilarityPercentage:.2f}%")
83+
84+
if Similarity > MaxSimilarity:
8685
MaxSimilarity = Similarity
8786
MostSimilarResponse = response
88-
87+
8988
# Convert MSR back into original string
90-
9189
for response in responses:
9290
lowresponse = response.lower()
93-
9491
if lowresponse == MostSimilarResponse:
9592
MostSimilarResponse = response
9693

9794
return MostSimilarResponse
95+

__pycache__/Janex.cpython-311.pyc

-4 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)