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

Commit d9420cf

Browse files
CipherCipher
authored andcommitted
FIXED IT. Capital letter detection (doubling), cosine similarity created.
1 parent 73093b6 commit d9420cf

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Janex/main.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ def response_compare(self, input_string, intent_class):
8484

8585
for response in responses:
8686
similarity = 0
87+
Count = 0
88+
InputCount = 0
8789
response_lower = response.lower()
8890
word_list = self.tokenize(response_lower)
8991
new_list = []
@@ -110,11 +112,20 @@ def response_compare(self, input_string, intent_class):
110112
else:
111113
similarity += 1
112114

113-
distance = abs(len(response) - len(input_string)) / 1000
115+
response_words = self.tokenize(response)
116+
input_words = self.tokenize(input_string)
114117

115-
print(distance)
118+
for word in response_words:
119+
Count += 0.01
116120

117-
similarity = similarity + distance
121+
for word in input_words:
122+
InputCount += 0.01
123+
124+
distance = Count + InputCount / 2
125+
126+
# print(distance)
127+
128+
similarity = similarity - distance
118129

119130
# Calculate the similarity percentage and the distance
120131
similarity_percentage = similarity / len(overall_word_list) # Calculate average similarity
@@ -123,7 +134,7 @@ def response_compare(self, input_string, intent_class):
123134
highest_similarity = similarity
124135
most_similar_response = response
125136

126-
print(f"Similarity: {highest_similarity:.2%}")
137+
print(f"Similarity: {similarity_percentage:.2%}")
127138
print(f"Distance: {distance}")
128139

129140
return most_similar_response

0 commit comments

Comments
 (0)