Today I programmed a program for preprocessing, and I made the code as class, but after this action, I got an error message as following:
TypeError: 'str' object is not callable
It makes no sense! I have always programmed the code as class in my work, there should be no mistakes in the process.
I found the reason why everyone encountered this error on the Internet. It was not until I saw the discussion on a forum that I realized what I programmed wrong.
The error message of the post in the forum is the same as mine, someone replied below that it was because "the object function that cannot be called was called".
As soon as I heard it, I checked my code again and finally found the problem.
When I initialized the preprocessing category, I defined the variable self.tokenizer
as the selected category of my word breaker, and then I used self.tokenizer()
again for the word segmentor as a function for processing.
To put it simply, I have repeated the name. This is really an easy mistake to make if you are not careful.
So I think that when there is such as this error message, the solution is to check the variable naming of your code.