Esempio n. 1
0
 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))
Esempio n. 2
0
            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