@@ -0,0 +1,1668 @@
+from gensim import corpora, models, similarities%0D%0A%0D%0Adocuments = %5B%0D%0A        %22Human machine interface for lab abc computer applications%22,%0D%0A        %22A survey of user opinion of computer system response time%22,%0D%0A        %22The EPS user interface management system%22,%0D%0A        %22System and human system engineering testing of EPS%22,%0D%0A        %22Relation of user perceived response time to error measurement%22,%0D%0A        %22The generation of random binary unordered trees%22,%0D%0A        %22The intersection graph of paths in trees%22,%0D%0A        %22Graph minors IV Widths of trees and well quasi ordering%22,%0D%0A        %22Graph minors A survey%22%5D%0D%0A%0D%0A# remove common words and tokenize%0D%0Astoplist = set('for a of the and to in'.split())%0D%0Atexts = %5B%5Bword for word in document.lower().split() if word not in stoplist%5D%0D%0A        for document in documents%5D%0D%0A%0D%0A# remove words that appear only once%0D%0Aall_tokens = sum(texts, %5B%5D)%0D%0Atokens_once = set(word for word in set(all_tokens) if all_tokens.count(word) == 1)%0D%0Atexts = %5B%5Bword for word in text if word not in tokens_once%5D%0D%0A        for text in texts%5D%0D%0A%0D%0A# Create dictionary%0D%0Adictionary = corpora.Dictionary(texts)%0D%0A%0D%0A# Define corpus%0D%0Acorpus = %5Bdictionary.doc2bow(text) for text in texts%5D%0D%0A%0D%0A# Define LSI space%0D%0Alsi = models.LsiModel(corpus, id2word=dictionary, num_topics=2)%0D%0A%0D%0A# Get similarity of teh doc vs documents%0D%0Adoc = %22Human computer interaction%22%0D%0Avec_bow = dictionary.doc2bow(doc.lower().split())%0D%0Avec_lsi = lsi%5Bvec_bow%5D # convert the query to LSI space%0D%0A%0D%0Aindex = similarities.MatrixSimilarity(lsi%5Bcorpus%5D) # transform corpus to LSI space and index it%0D%0Asims = index%5Bvec_lsi%5D # perform a similarity query against the corpus%0D%0Aprint(list(enumerate(sims))) #

Test nlp