Skip to main content

Does anyone know if the FuzzyStringComparer has compatability issues with 2017.0?

I am getting the following error in the log when trying to use it.

2017-04-26 13:37:48| 0.3| 0.0|ERROR |Python Exception <AttributeError>: 'float' object has no attribute 'lower'

2017-04-26 13:37:48| 0.3| 0.0|ERROR |Error encountered while calling function `FuzzyStringCompare'

2017-04-26 13:37:48| 0.3| 0.0|FATAL |f_9(PythonFactory): PythonFactory failed to process feature

If it is an issue with compatibility, is there another transformer I can use to do the same thing?

Thanks

Could it be that one of your attributes contains a float rather than a string?

Try forcing the attributes used by the FuzzyStringComparer to strings using a format string of "s", e.g.


Thanks David_r

I have tried that but without success.

The message I get now is

2017-04-26 13:49:30| 0.3| 0.0|ERROR |Python Exception <AttributeError>: 'long' object has no attribute 'lower'

2017-04-26 13:49:30| 0.3| 0.0|ERROR |Error encountered while calling function `FuzzyStringCompare'

2017-04-26 13:49:30| 0.3| 0.0|FATAL |f_11(PythonFactory): PythonFactory failed to process featur

Thanks


Did you send both your attributes through the StringFormatter? These two:


You can also modify the two lines in the PythonCaller of the FuzzyStringComparer as follows:

    string1 = str(feature.getAttribute('FuzzyStringCompare.string1') or '').lower()
    string2 = str(feature.getAttribute('FuzzyStringCompare.string2') or '').lower()

This will accomplish about the same thing.


I will give it a go

Thanks


You are not the first to note that there are issues with the transformer:

https://knowledge.safe.com/questions/43217/fuzzystringcomparer-many-versions-many-issues.html

maybe somebody from Safe can provide some info on the matter....


You can also modify the two lines in the PythonCaller of the FuzzyStringComparer as follows:

    string1 = str(feature.getAttribute('FuzzyStringCompare.string1') or '').lower()
    string2 = str(feature.getAttribute('FuzzyStringCompare.string2') or '').lower()

This will accomplish about the same thing.

Agree. The current FuzzyStringComparer raises an error if a specified attribute contains a non-string type value, or the attribute is missing. The code provided by @david_r would a quick workaround, but I think there still is a room to improve.

 

  • Casting to str instance could cause an error, if a specified attribute contains a unicode instance representing a character incompatible to ascii code. The error occurs only with Python 2.7, won't occur with Python 3.x.
  • If a specified attribute contains numeric 0 (int or float value), the right hand side of the expression returns the empty string since the numeric 0 as an operand in a logical expression will be interpreted as False by Python interpreter. 
@RylanAtSafe, please consider doing further improving ;)
Agree. The current FuzzyStringComparer raises an error if a specified attribute contains a non-string type value, or the attribute is missing. The code provided by @david_r would a quick workaround, but I think there still is a room to improve.

 

  • Casting to str instance could cause an error, if a specified attribute contains a unicode instance representing a character incompatible to ascii code. The error occurs only with Python 2.7, won't occur with Python 3.x.
  • If a specified attribute contains numeric 0 (int or float value), the right hand side of the expression returns the empty string since the numeric 0 as an operand in a logical expression will be interpreted as False by Python interpreter.
@RylanAtSafe, please consider doing further improving ;)
Definitely needs cleaning up to catch those special cases, yes.

Reply