0

In Java, a custom similarity scoring function is created by extending the SimilarityBase Class and overriding the scoring method. However, I cannot find a way to do the same using pylucene.

I have tried extending the SimilarityBase class the same way as we do in Java.

class CustomSimilarity(SimilarityBase):
        def __init__(self):
        SimilarityBase.__init__(self)

    def score(self,stats,termfreq,doclen):
        return termfreq

    def toString(self):
        return "Term Frequency Scoring"

However, I get an error during the allocation of the CustomSimilairity Class to my Index Searcher

lucene.JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
java.lang.InstantiationException: 

1 Answers1

0

I found a solution. I don't understand why this is correct though.

class CustomSimilarity(SimilarityBase):
    def __init__(self):
        #self.super = SimilarityBase()
        pass

    def score(self,stats,termfreq,doclen):
        return termfreq

    def toString(self):
        return "Term Frequency Scoring"