Update app.py
Browse files
app.py
CHANGED
@@ -60,6 +60,9 @@ async def train_and_save_model():
|
|
60 |
continue
|
61 |
|
62 |
for intent in intents['intents']:
|
|
|
|
|
|
|
63 |
for pattern in intent['patterns']:
|
64 |
w = nltk.word_tokenize(pattern)
|
65 |
words.extend(w)
|
@@ -68,6 +71,9 @@ async def train_and_save_model():
|
|
68 |
classes.append(intent['tag'])
|
69 |
|
70 |
for _ in range(100000):
|
|
|
|
|
|
|
71 |
new_pattern = []
|
72 |
for word in random.choice(intent['patterns']).split():
|
73 |
synonyms = wordnet.synsets(word)
|
@@ -78,6 +84,8 @@ async def train_and_save_model():
|
|
78 |
new_pattern.append(word)
|
79 |
intent['patterns'].append(" ".join(new_pattern))
|
80 |
|
|
|
|
|
81 |
words = [lemmatizer.lemmatize(w.lower()) for w in words if w not in ignore_words]
|
82 |
words = sorted(list(set(words)))
|
83 |
|
|
|
60 |
continue
|
61 |
|
62 |
for intent in intents['intents']:
|
63 |
+
if not intent['patterns']:
|
64 |
+
continue
|
65 |
+
|
66 |
for pattern in intent['patterns']:
|
67 |
w = nltk.word_tokenize(pattern)
|
68 |
words.extend(w)
|
|
|
71 |
classes.append(intent['tag'])
|
72 |
|
73 |
for _ in range(100000):
|
74 |
+
if not intent['patterns']:
|
75 |
+
break
|
76 |
+
|
77 |
new_pattern = []
|
78 |
for word in random.choice(intent['patterns']).split():
|
79 |
synonyms = wordnet.synsets(word)
|
|
|
84 |
new_pattern.append(word)
|
85 |
intent['patterns'].append(" ".join(new_pattern))
|
86 |
|
87 |
+
print(f"Generated patterns for intent '{intent['tag']}': {intent['patterns'][:10]}")
|
88 |
+
|
89 |
words = [lemmatizer.lemmatize(w.lower()) for w in words if w not in ignore_words]
|
90 |
words = sorted(list(set(words)))
|
91 |
|