def __init__(self, config): if isinstance(config, (int)): self.context = strus.Context("localhost:%u" % config) self.storage = self.context.createStorageClient() else: self.context = strus.Context() self.context.addResourcePath("./resources") self.storage = self.context.createStorageClient(config) self.queryAnalyzer = self.createQueryAnalyzer() self.documentAnalyzer = self.createDocumentAnalyzer() self.queryeval = {} self.queryeval["BM25"] = self.createQueryEvalBM25() self.queryeval["NBLNK"] = self.createQueryEvalNBLNK()
def __init__(self, config): # Open local storage on file with configuration specified: self.context = strus.Context() self.storage = self.context.createStorageClient(config) self.queryeval = {} for scheme in [ "BM25", "BM25pg", "BM25pff", "BM25std", "NBLNK", "TILNK", "VCLNK", "STDLNK" ]: self.queryeval[scheme] = self.createQueryEval(scheme)
def __init__(self, config): # Open local storage on file with configuration specified: self.context = strus.Context() self.storage_dym = self.context.createStorageClient( config ) self.queryeval_dym = self.createQueryEval_dym() # dym = did you mean ... ? self.analyzer = self.context.createQueryAnalyzer() self.analyzer.addSearchIndexElement( "ngram", "dym", "word", ["lc", [ "ngram", "WithStart", 3]] ) self.analyzer.addSearchIndexElement( "word", "word", "word", ["lc", [ "convdia", "en"]] )
if len(sys.argv) > 2: outputdir = sys.argv[2] else: outputdir = "." if len(sys.argv) > 3: ctxconfig = getContextConfig(sys.argv[3], testname) else: ctxconfig = None storage = outputdir + "/storage" docfiles = ["A.xml", "B.xml", "C.xml"] withrpc = False if ctxconfig and 'rpc' in ctxconfig: withrpc = True ctx = strus.Context(ctxconfig) aclmap = {"A.xml": "a", "B.xml": "b", "C.xml": "c"} createCollection(ctx, storage, metadata_umlaut_t3s(), createDocumentAnalyzer_umlaut_t3s(ctx), False, datadir, docfiles, aclmap, withrpc) result = "collection dump:" + dumpTree(dumpCollection(ctx, storage)) + "\n" expected = """collection dump: str config: str acl: "true" str cache: "524288K" str metadata: str doclen: "UInt16" str title_end: "UInt8" str title_start: "UInt8" str path: "storage"
import heapq import optparse import signal import strus import strusMessage # [0] Globals and helper classes: # The address of the global statistics server: statserver = "localhost:7183" # Strus storage server addresses: storageservers = [] # Strus client connection factory: msgclient = strusMessage.RequestClient() # Query analyzer structures (parallel to document analyzer definition in strusIR): strusctx = strus.Context() analyzer = strusctx.createQueryAnalyzer() analyzer.addElement("word", "text", "word", ["lc", ["stem", "en"], ["convdia", "en"]]) # Query evaluation structures: ResultRow = collections.namedtuple( 'ResultRow', ['docno', 'docid', 'weight', 'title', 'abstract']) # [1] HTTP handlers: # Answer a query (issue a query to all storage servers and merge it to one result): class QueryHandler(tornado.web.RequestHandler): @tornado.gen.coroutine def queryStats(self, terms): rt = ([], 0, None)
def __init__(self, config): # Open local storage on file with configuration specified: self.context = strus.Context() self.storage = self.context.createStorageClient(config) self.documentAnalyzer = self.createDocumentAnalyzer() self.queryeval = self.createQueryEvalBM25()
import strus import os x = strus.Context()