Search code examples
pythonnltkwordnet

Arguments to res_similarity() function


I am using resnik similarity algorithm to find similarity between two synsets and I am using it in the following way in python:

def get_maximum(synset1,synset2):
    maxSim = None
    for s1 in synset1:
          for s2 in synset2:
               sim = s1.res_similarity(s2)
               if maxSim == None or maxSim < sim:
                     maxSim = sim
    return maxSim

Here I am getting following error:

Typeerror: res_similarity() takes at least 3 arguments (2 given)

Can somebody tell me which one is third argument?


Solution

  • Typeerror from docs:

    Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details about the type mismatch.

    At you case you have a function names res_similarity() that need to take 2 arguments.

    The reason you see 3 and 2 given is because it has also self.

    For example res_similarity(self, arg1, arg2) you are passing only 1 parameter - s2

    You need to pass one more parameter to this method