当前位置: 首页>>代码示例>>Python>>正文


Python IndexSearcher.maxDoc方法代码示例

本文整理汇总了Python中lucene.IndexSearcher.maxDoc方法的典型用法代码示例。如果您正苦于以下问题:Python IndexSearcher.maxDoc方法的具体用法?Python IndexSearcher.maxDoc怎么用?Python IndexSearcher.maxDoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lucene.IndexSearcher的用法示例。


在下文中一共展示了IndexSearcher.maxDoc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: search2

# 需要导入模块: from lucene import IndexSearcher [as 别名]
# 或者: from lucene.IndexSearcher import maxDoc [as 别名]
def search2():
    results0=[]
    results2=[]
    loc=[]
    sr=''
    tmp='' 
    mark=False
    if request.method == 'POST':
        try:                        
            initVM()       
            directory = SimpleFSDirectory(File('albumIndex'))
            searcher2 = IndexSearcher(directory, True)
            analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)

            if "Search" in request.form.values():
                sr=request.form['text']
                
            elif "Shuffle" in request.form.values():
                mark=True
                while len(loc)<20:
                    tmp=random.randint(0,searcher2.maxDoc()-1)
                    if tmp not in loc:
                        loc+=[tmp]
                

            if mark:
                print 'loc=',loc
                ct=0
                for i in loc:
                    doc = searcher2.doc(i)
                    songs=doc.get('albumsongs')
                    songs=songs.split('[email protected]#$%')
                    urls=doc.get("albumsongURLs")
                    urls=urls.split('[email protected]#$%')
                    results2+=[{'albumnum': doc.get("albumnum"),\
                               'albumname':doc.get('albumname'),\
                                'albumartist':doc.get('albumartist'),\
                               'albumintro': doc.get("albumintro"),\
                               'albumsongs':songs,\
                               'albumsongURLs': urls,\
                               'albumpicURL':doc.get('albumpicURL'),\
                                'albumartistURL':doc.get('albumartistURL'),\
                                'albumURL':doc.get('albumURL'),\
                               'rank':100}]
            else:
                print  request.form.values()
                print 'sr=',sr
                if sr=='':
                    return results0,results2,""
##                for i in sr:
##                    tmp+=i+" "
##                print tmp
                scoreDocs=run2(searcher2, analyzer,sr,1) #search exact album

                if scoreDocs!=False:
                    doc=scoreDocs
                    songs=doc.get('albumsongs')
                    songs=songs.split('[email protected]#$%')
                    urls=doc.get("albumsongURLs")
                    urls=urls.split('[email protected]#$%')
                    results2+=[{'albumnum': doc.get("albumnum"),\
                               'albumname':doc.get('albumname'),\
                                'albumartist':doc.get('albumartist'),\
                               'albumintro': doc.get("albumintro"),\
                               'albumsongs':songs,\
                               'albumsongURLs': urls,\
                               'albumpicURL':doc.get('albumpicURL'),\
                                'albumartistURL':doc.get('albumartistURL'),\
                                'albumURL':doc.get('albumURL'),\
                               'rank':100}] 
                    results0=results2
                else:
                    scoreDocs=run2(searcher2, analyzer,sr,20) #search 20 albums
                    rank=100
                    for scoreDoc in scoreDocs:
                        doc = searcher2.doc(scoreDoc.doc)
                        songs=doc.get('albumsongs')
                        songs=songs.split('[email protected]#$%')
                        urls=doc.get("albumsongURLs")
                        urls=urls.split('[email protected]#$%')
                        results2+=[{'albumnum': doc.get("albumnum"),\
                               'albumname':doc.get('albumname'),\
                                'albumartist':doc.get('albumartist'),\
                               'albumintro': doc.get("albumintro"),\
                               'albumsongs':songs,\
                               'albumsongURLs': urls,\
                               'albumpicURL':doc.get('albumpicURL'),\
                                'albumartistURL':doc.get('albumartistURL'),\
                                'albumURL':doc.get('albumURL'),\
                                    'rank':rank}]
                        rank-=5
            conn = MySQLdb.connect(host='localhost', user='root',passwd='1234',charset="utf8") 
            # conn = MySQLdb.connect(host='localhost', user='ee208',passwd='ee208',charset="utf8")
            conn.select_db('coversearch');
            cursor = conn.cursor()
            
            for i in results2:
                try:
                    cursor.execute("select zan from albums where id="+i['albumnum'])
                    zan=cursor.fetchone()[0]
#.........这里部分代码省略.........
开发者ID:morningmoni,项目名称:CoverSearch,代码行数:103,代码来源:web.py

示例2: search

# 需要导入模块: from lucene import IndexSearcher [as 别名]
# 或者: from lucene.IndexSearcher import maxDoc [as 别名]
def search():
    results=[]
    results3=[]
    loc=[]
    sr=''
    tmp='' 
    mark=False
    if request.method == 'POST':
        try:                        
            initVM()       
            directory = SimpleFSDirectory(File("songIndex"))
            searcher = IndexSearcher(directory, True)
            directory = SimpleFSDirectory(File("artistIndex"))
            searcher3 = IndexSearcher(directory, True)
            analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)

            if "Search" in request.form.values():
                sr=request.form['text']
                
            elif "Shuffle" in request.form.values():
                mark=True
                while len(loc)<20:
                    tmp=random.randint(0,searcher.maxDoc()-1)
                    if tmp not in loc:
                        loc+=[tmp]
                
##            if request.form['action']=="Search":
##                sr=request.form['text']
##            elif request.form['action']=="Shuffle":
##                sr='1'


            if mark:
                print 'loc=',loc
                for i in loc:
                    doc = searcher.doc(i)
                    results+=[{'songname':doc.get("songname"),\
                               'songurl':doc.get('songurl'),\
                               'albumname':doc.get('songalbum'),\
                               'songartist':doc.get('songartist'),\
                               'albumurl': doc.get("songalbumURL"),\
                               'picPath':doc.get('songpicURL'),\
                               }]                   
            else:
                print  request.form.values()
                print 'sr=',sr
                if sr=='':
                    return results,results3,""
                for i in sr:
                   tmp+=i+" "
##                print tmp
##                scoreDocs=run2(searcher2, analyzer,sr)
##                if len(scoreDocs)!=0:
##                    doc=searcher2.doc(scoreDocs[0].doc)
##                    results2+=[{'albumnum:', doc.get("albumnum"),\
##                               'albumname:',doc.get('albumname'),\
##                                'albumartist:',doc.get('albumartist'),\
##                               'albumintro:', doc.get("albumintro"),\
##                               'albumsongs:',doc.get('albumsongs'),\
##                               'albumsongURLs:', doc.get("albumsongURLs"),\
##                               'albumpicURL:',doc.get('albumpicURL')}]
##                else:
                scoreDocs=run3(searcher3,analyzer,sr)
                if scoreDocs == False:
                    scoreDocs=run(searcher, analyzer,sr)
                    for scoreDoc in scoreDocs:
                        doc = searcher.doc(scoreDoc.doc)
                        results+=[{'songname':doc.get("songname"),\
                                   'songurl':doc.get('songurl'),\
                                   'albumname':doc.get('songalbum'),\
                                   'songartist':doc.get('songartist'),\
                                   'albumurl': doc.get("songalbumURL"),\
                                   'picPath':doc.get('songpicURL')\
                                   }]
                else:
                    doc=scoreDocs
                    singeralbums=doc.get('singeralbums')
                    singeralbums=singeralbums.split('[email protected]#$%')
                    singeralbumURLs=doc.get("singeralbumURLs")
                    singeralbumURLs=singeralbumURLs.split('[email protected]#$%')
                    results3+=[{'singername': doc.get("singername"),\
                                'singerplace':doc.get('singerplace'),\
                                'singerintro':doc.get('singerintro'),\
                                'singeralbums': singeralbums,\
                               'singeralbumURLs':singeralbumURLs,\
                                'singerpicURL': doc.get("singerpicURL")\
                                }]
            searcher.close()
        except Exception,e:
            print 1,e
开发者ID:morningmoni,项目名称:CoverSearch,代码行数:92,代码来源:web.py

示例3: list

# 需要导入模块: from lucene import IndexSearcher [as 别名]
# 或者: from lucene.IndexSearcher import maxDoc [as 别名]
    #   print ngram
    import itertools
    list_of_NNPs.sort()
    unique_NNPs = list(list_of_NNPs for list_of_NNPs,_ in itertools.groupby(list_of_NNPs))
    return unique_NNPs    





     
if __name__ == '__main__':
    
    reload(sys)
    sys.setdefaultencoding('iso-8859-1')
    
    STORE_DIR = None
    while STORE_DIR == None:
        path = raw_input("What's the path to the index :")
        if path != '' and path != None :
            STORE_DIR = path
    
    initVM()
    print 'lucene', VERSION
    directory = SimpleFSDirectory(File(STORE_DIR))
    searcher = IndexSearcher(directory, True)
    print searcher.maxDoc()
    analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)
    run(searcher, analyzer)
    searcher.close()
开发者ID:linares,项目名称:fwiki,代码行数:32,代码来源:TaxonomySearch.py


注:本文中的lucene.IndexSearcher.maxDoc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。