We recommend switching to the latest versions of Edge, Firefox, Chrome or Safari. Using Internet Explorer will result in a loss of website functionality.

String Percent Match

Comments

1 comment

  • Avatar
    Adrian Williams

    You could investigate some of the options described in this StackOverflow post.

     

    Here is the equivalent of the first example in the post using a Transform node.

     

     

    #### ConfigureFields Script

    from difflib import SequenceMatcher

    #Configure all fields from input 'in1' to be mapped
    #to the corresponding fields on the output 'out1'
    out1 += in1

    out1.MatchRatio = float

    def strSimilar(a, b):
      if (a is Null or b is Null):
        return Null
      else:
        return SequenceMatcher(None, a, b).ratio()

    #### End ConfigureFields Script

     

    #### ProcessRecords Script

    #Copy all fields from input 'in1' to the corresponding output fields
    #in output 'out1'. Copies the values of the fields that have been setup
    #in the mapping defined in the ConfigureFields property
    out1 += in1

    out1.MatchRatio = strSimilar(fields.StringA, fields.StringB)

    #### End ProcessRecords Script

     

    Note, you may need to use the Python node rather than the Transform node if you are interested in using 3rd party Python packages. 

     

    0
    Comment actions Permalink

Please sign in to leave a comment.