def __init__(self, index_dir_ngram='./ngram', index_dir_vocab='./vocab'): self._index_dir_ngram = index_dir_ngram self._index_dir_vocab = index_dir_vocab fs = MMapDirectory.open(File(index_dir_ngram)) self._searcher_ngram = IndexSearcher(DirectoryReader.open(fs))
sys.exit(1) try: print("creating index:", fname) IndexFiles(sys.argv[1], fname, analyzer, not opts.all_line) end = datetime.now() print(end - start) except Exception as e: print("Failed: ", e) raise e print("loading index:", fname) else: print("creating index...") if opts.simple_fs: directory = SimpleFSDirectory(File(fname)) else: directory = MMapDirectory.open(File(fname)) dir_reader = DirectoryReader.open(directory) searcher = IndexSearcher(dir_reader) index = Index(searcher, analyzer, opts.verbose) if opts.server: from . import server server.run(opts.port, index) else: index.prompt(opts.max_n) del searcher