You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs = [simple_preprocess(content) for content in input]
dictionary = Dictionary(docs)
dictionary.filter_extremes(no_below=1)
corpus = [dictionary.doc2bow(tokens) for tokens in docs]
model = LdaModel(corpus, num_topics=20)
for content, bow in zip(input, corpus):
embedding = Vector([v[1] for v in model.get_document_topics(bow, minimum_probability=0)])
conn.execute('INSERT INTO documents (content, embedding) VALUES (%s, %s)', (content, embedding))
document_id = 1
neighbors = conn.execute('SELECT content FROM documents WHERE id != %(id)s ORDER BY embedding <=> (SELECT embedding FROM documents WHERE id = %(id)s) LIMIT 5', {'id': document_id}).fetchall()