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

Commit cba0c90

Browse files
CipherCipher
authored andcommitted
Cosine similarity finished. I need to reimplement word matching as it appears faulty. Somewhat usable, not massively.
1 parent 29016a8 commit cba0c90

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Janex/main.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,16 @@ def response_compare(self, input_string, intent_class):
104104

105105
for word in word_list_2:
106106
if word in word_list:
107-
# Check if the word begins with a capital letter
107+
# Check if the word begins with a capital letter
108108
if word.istitle():
109109
similarity += 2 # Add 2 to the similarity for words with capital letters
110110
else:
111111
similarity += 1
112112

113113
# Calculate the similarity percentage and the distance
114-
similarity_percentage = similarity / (len(overall_word_list) + len(word_list_2))
114+
similarity_percentage = similarity / len(overall_word_list) # Calculate average similarity
115+
116+
# Calculate the distance between response and input_string
115117
distance = abs(len(response) - len(input_string))
116118

117119
# Combine similarity and distance with appropriate weights
@@ -138,9 +140,10 @@ def stem(self, input_word):
138140
def stem_sentence(self, input_string):
139141
word_list = input_string.split(" ")
140142
stemmed_words = []
143+
141144
for input_word in word_list:
142145
word = self.stem(input_word)
143-
stemmed_words.append(word)
146+
stemmed_word.append(word)
144147

145148
return stemmed_words
146149

0 commit comments

Comments
 (0)