Search code examples
pythonmysqltext-search

Python - Library that compute relevance score for text search


My idea is to achieve an execution similar to the MySQL MATCH / AGAINST keywords.

Do you know a python library that compute relevance score for text searches?

If not satisfying answers I am going to use a Python connector to MySQL.


Solution

  • Have a look at PyLucene http://lucene.apache.org/pylucene/

    import os, sys, unittest, lucene
    lucene.initVM()
    
    baseDir = os.path.dirname(os.path.abspath(sys.argv[0]))
    sys.path.append(baseDir)
    
    import lia.searching.ScoreTest
    from lucene import System
    
    System.setProperty("index.dir", os.path.join(baseDir, 'index'))
    unittest.main(lia.searching.ScoreTest)
    

    You can found more examples and lia at http://svn.apache.org/viewvc/lucene/pylucene/trunk/samples/LuceneInAction/