Exemple #1
0
    def getPkgname(self, title):
        print "in get Pkgname,query :" + title
        if isinstance(title, unicode):
            title = title.encode('utf-8')
        retArr = QPAccessor.getQPSegQuery(title)
        pkgSet = set(self.word_pkgSet_dict[retArr[0]])
        pkg_titleLen_dict = {}
        for word in retArr:
            pkgSet = pkgSet & self.word_pkgSet_dict[word]
        if len(pkgSet) > 0:
            for pkg in pkgSet:
                pkg_titleLen_dict[pkg] = len(self.pkg_game_dict[pkg][1])
                print pkg,
            pkg_titleLen_list = sorted(pkg_titleLen_dict.items(),
                                       key=lambda e: e[1],
                                       reverse=False)
            print "\n" + str(len(pkgSet)) + "matches for " + title
            print "length for " + pkg_titleLen_list[0][0] + ":" + str(
                pkg_titleLen_list[0][1])
            return pkg_titleLen_list[0][0]

        print "title:" + title + " does not match any title"
        return "None"
Exemple #2
0
        print 'load data'
        f = file('pkg_topSimilarity_dict.data')
        self.topSim_dict = p.load(f)
        f.close()

        f = file('pkg_tfidf_dict.data')
        self.per_pkg_word_weight_dict = p.load(f)
        f.close()
        print "first testing"
        #print "desp sim for com.furiousapps.haunt2 and com.rexsee.fch.spm6l2:" + str(self.despSim_dict['com.furiousapps.haunt2']['com.rexsee.fch.spm6l2'])
        #print "top sim for com.furiousapps.haunt2 and air.mgg1beautifulteendressup"  + str(self.topSim_dict['com.furiousapps.haunt2']['air.mgg1beautifulteendressup'])


if __name__ == '__main__':
    print "test QPAccessor"
    retArr = QPAccessor.getQPSegQuery('愤怒的小鸟')
    for item in retArr:
        print item

    s = Server()
    s.loadData()
    s.inputGame()
    s.buildWordPkgSet()
    print s.getPkgname('愤怒的小鸟')

    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    sock.bind(('10.99.20.96', 8849))
    sock.listen(5)
    print "\n socket start"
    while True:
Exemple #3
0
#encoding=utf8
import sys, os
curPath = os.path.abspath(os.path.split(os.path.realpath(__file__))[0])
sys.path.append(curPath + "/../common/")
sys.path.append(curPath + "/../filter/")
sys.path.append(curPath + "/../")
from qp_accessor import QPAccessor
reload(sys)
sys.setdefaultencoding("UTF8")

if __name__ == '__main__':

    print "test QPAccessor"
    retArr = QPAccessor.getQPSegQuery('炫彩泡泡龙')

    for item in retArr:
        print item