minor improvements
This commit is contained in:
+3
-7
@@ -246,20 +246,16 @@ def info_name(package_name):
|
|||||||
def search_package_terms(terms, lang = None):
|
def search_package_terms(terms, lang = None):
|
||||||
if not lang:
|
if not lang:
|
||||||
lang = pisi.pxml.autoxml.LocalText.get_lang()
|
lang = pisi.pxml.autoxml.LocalText.get_lang()
|
||||||
def search(self, id, terms):
|
|
||||||
return pisi.search.query(id, lang, terms)
|
|
||||||
r1 = pisi.search.query_terms('summary', lang, terms)
|
r1 = pisi.search.query_terms('summary', lang, terms)
|
||||||
r2 = pisi.search.query_terms('description', lang, terms)
|
r2 = pisi.search.query_terms('description', lang, terms)
|
||||||
r = r1.union(r2)
|
r = r1.union(r2)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def search_package(terms, lang = None):
|
def search_package(query, lang = None):
|
||||||
if not lang:
|
if not lang:
|
||||||
lang = pisi.pxml.autoxml.LocalText.get_lang()
|
lang = pisi.pxml.autoxml.LocalText.get_lang()
|
||||||
def search(self, id, terms):
|
r1 = pisi.search.query('summary', lang, query)
|
||||||
return pisi.search.query(id, lang, terms)
|
r2 = pisi.search.query('description', lang, query)
|
||||||
r1 = pisi.search.query('summary', lang, terms)
|
|
||||||
r2 = pisi.search.query('description', lang, terms)
|
|
||||||
r = r1.union(r2)
|
r = r1.union(r2)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class Exception(pisi.Exception):
|
|||||||
# API
|
# API
|
||||||
|
|
||||||
from invertedindex import InvertedIndex
|
from invertedindex import InvertedIndex
|
||||||
from preprocess import preprocess
|
import preprocess as p
|
||||||
|
|
||||||
def init(ids, langs):
|
def init(ids, langs):
|
||||||
"initialize databases"
|
"initialize databases"
|
||||||
@@ -48,17 +48,16 @@ def finalize():
|
|||||||
ctx.invidx = {}
|
ctx.invidx = {}
|
||||||
|
|
||||||
def add_doc(id, lang, docid, str, txn = None):
|
def add_doc(id, lang, docid, str, txn = None):
|
||||||
terms = preprocess(lang, str)
|
terms = p.preprocess(lang, str)
|
||||||
ctx.invidx[id][lang].add_doc(docid, terms, txn)
|
ctx.invidx[id][lang].add_doc(docid, terms, txn)
|
||||||
|
|
||||||
def remove_doc(id, lang, docid, str, txn = None):
|
def remove_doc(id, lang, docid, str, txn = None):
|
||||||
ctx.invidx[id][lang].remove_doc(docid, txn)
|
ctx.invidx[id][lang].remove_doc(docid, txn)
|
||||||
|
|
||||||
def query_terms(id, lang, terms, txn = None):
|
def query_terms(id, lang, terms, txn = None):
|
||||||
import preprocess as p
|
|
||||||
terms = map(lambda x: p.lower(lang, x), terms)
|
terms = map(lambda x: p.lower(lang, x), terms)
|
||||||
return ctx.invidx[id][lang].query(terms, txn)
|
return ctx.invidx[id][lang].query(terms, txn)
|
||||||
|
|
||||||
def query(id, lang, str, txn = None):
|
def query(id, lang, str, txn = None):
|
||||||
terms = preprocess(lang, str)
|
terms = p.preprocess(lang, str)
|
||||||
return query_terms(id, lang, terms, txn)
|
return query_terms(id, lang, terms, txn)
|
||||||
|
|||||||
Reference in New Issue
Block a user