[pylucene-dev] extend Similarity -- but only want to overide one func: lengthNorm()

Andi Vajda vajda at osafoundation.org
Thu Mar 8 08:46:07 PST 2007


On Thu, 8 Mar 2007, John Kleven wrote:

> Is it possible extend the Similarity class via
> PyLucene but only to override one function, namely
> lengthNorm()?
>
> I've seen the examples in ScoreTest.py and
> test_similarity.py, and they both take over *all*
> functions, but i would like to just get whatever
> default behaviour i was getting before via Similarity,
> except for i need to tweak lengthNorm a bit.
>

The Java Lucene Similarity class is abstract. PythonSimilarity, the way to 
implement it in python directly extends it and hence requires all abstract 
Similarity methods to be implemented.

This could be done, however, by making it possible to use a 
SimilarityDelegator instance (currently missing in PyLucene) with a python 
object implementing only certain Similarity methods. 
http://lucene.apache.org/java/docs/api/org/apache/lucene/search/SimilarityDelegator.html

More about this in a bit...

Andi..


More information about the pylucene-dev mailing list