Skip to main content
Question

Fuzzy String Comparer


bubblebeb
Contributor
Forum|alt.badge.img+6

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

8 replies

david_r
Celebrity
  • April 26, 2017

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.


bubblebeb
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • April 26, 2017

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


david_r
Celebrity
  • April 26, 2017

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


david_r
Celebrity
  • April 26, 2017

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.


bubblebeb
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • April 26, 2017

I will give it a go

Thanks


itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • April 26, 2017

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....


takashi
Influencer
  • April 27, 2017
david_r wrote:

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 ;)

david_r
Celebrity
  • April 28, 2017
takashi wrote:
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.

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings