def run(self): if self.items is None: write("[+] Loading items:") if self.debug else '' self.items = json.loads(open(options['--input']).read()) self.data = Data(self.items, preprocess=options['--preprocess'], debug=self.debug) write("\n[+] Creating the vector space:") if self.debug else '' vsm = VectorSpace(self.data.texts, method=options['--method'], debug=self.debug) write("[+] Generating recommendations".ljust( 54, '.')) if self.debug else '' rec_items = self.generate_rec(vsm) write("[OK]\n") if self.debug else '' write("[+] Saving to output file".ljust( 54, '.')) if options['--debug'] else '' json.dump(rec_items, open(options['--output'], 'w')) write("[OK]\n") print "[x] Finished."
from vector_space import VectorSpace vector_space = VectorSpace([ "The cat in the hat disabled", "A cat is a fine pet ponies.", "Dogs and cats make good pets.", "I haven't got a hat." ]) print("start") print(vector_space.search(["cat"])) print(vector_space.ralated(0))