Jaro distance in MMA

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite
2












I'm trying to program Jaro distance as requested by this page I've done the following code that works well for the next two pairs ("MARTHA", "MARHTA") and ("DIXON", "DICKSONX") but when I try with ("JELLYFISH", "SMELLYFISH") I get an error because the code counts the double S of "SMELLYFISH", due to this error I have not been able to finish successfully, here is what I have programmed up to this moment



uno = "DIXON"; dos ="DICKSONX" ;
rep = Characters[uno] [Intersection] Characters[dos]
scope = Max[StringLength[uno], StringLength[dos]]/2 - 1
inter = Transpose[Flatten[Position[Characters[uno], #] & /@ rep],
Flatten[Position[Characters[dos], #] & /@ rep]]

m = Select[inter, Abs[#[[1]] - #[[2]]] < scope &]

prb = Select[m, #[[1]] != #[[2]] &]

trans = Length[DeleteCases[Position[prb, Reverse[#]] & /@ prb, ]]/2

1/3 (Length[m]/StringLength[uno] + Length[m]/StringLength[dos] + (
Length[m] - trans)/Length[m])

% // N


Someone who can help me solve this problem? Maybe the approach I'm using is wrong, I hope someone is interested in this problem too. Thanks in advance










share|improve this question

























    up vote
    4
    down vote

    favorite
    2












    I'm trying to program Jaro distance as requested by this page I've done the following code that works well for the next two pairs ("MARTHA", "MARHTA") and ("DIXON", "DICKSONX") but when I try with ("JELLYFISH", "SMELLYFISH") I get an error because the code counts the double S of "SMELLYFISH", due to this error I have not been able to finish successfully, here is what I have programmed up to this moment



    uno = "DIXON"; dos ="DICKSONX" ;
    rep = Characters[uno] [Intersection] Characters[dos]
    scope = Max[StringLength[uno], StringLength[dos]]/2 - 1
    inter = Transpose[Flatten[Position[Characters[uno], #] & /@ rep],
    Flatten[Position[Characters[dos], #] & /@ rep]]

    m = Select[inter, Abs[#[[1]] - #[[2]]] < scope &]

    prb = Select[m, #[[1]] != #[[2]] &]

    trans = Length[DeleteCases[Position[prb, Reverse[#]] & /@ prb, ]]/2

    1/3 (Length[m]/StringLength[uno] + Length[m]/StringLength[dos] + (
    Length[m] - trans)/Length[m])

    % // N


    Someone who can help me solve this problem? Maybe the approach I'm using is wrong, I hope someone is interested in this problem too. Thanks in advance










    share|improve this question























      up vote
      4
      down vote

      favorite
      2









      up vote
      4
      down vote

      favorite
      2






      2





      I'm trying to program Jaro distance as requested by this page I've done the following code that works well for the next two pairs ("MARTHA", "MARHTA") and ("DIXON", "DICKSONX") but when I try with ("JELLYFISH", "SMELLYFISH") I get an error because the code counts the double S of "SMELLYFISH", due to this error I have not been able to finish successfully, here is what I have programmed up to this moment



      uno = "DIXON"; dos ="DICKSONX" ;
      rep = Characters[uno] [Intersection] Characters[dos]
      scope = Max[StringLength[uno], StringLength[dos]]/2 - 1
      inter = Transpose[Flatten[Position[Characters[uno], #] & /@ rep],
      Flatten[Position[Characters[dos], #] & /@ rep]]

      m = Select[inter, Abs[#[[1]] - #[[2]]] < scope &]

      prb = Select[m, #[[1]] != #[[2]] &]

      trans = Length[DeleteCases[Position[prb, Reverse[#]] & /@ prb, ]]/2

      1/3 (Length[m]/StringLength[uno] + Length[m]/StringLength[dos] + (
      Length[m] - trans)/Length[m])

      % // N


      Someone who can help me solve this problem? Maybe the approach I'm using is wrong, I hope someone is interested in this problem too. Thanks in advance










      share|improve this question













      I'm trying to program Jaro distance as requested by this page I've done the following code that works well for the next two pairs ("MARTHA", "MARHTA") and ("DIXON", "DICKSONX") but when I try with ("JELLYFISH", "SMELLYFISH") I get an error because the code counts the double S of "SMELLYFISH", due to this error I have not been able to finish successfully, here is what I have programmed up to this moment



      uno = "DIXON"; dos ="DICKSONX" ;
      rep = Characters[uno] [Intersection] Characters[dos]
      scope = Max[StringLength[uno], StringLength[dos]]/2 - 1
      inter = Transpose[Flatten[Position[Characters[uno], #] & /@ rep],
      Flatten[Position[Characters[dos], #] & /@ rep]]

      m = Select[inter, Abs[#[[1]] - #[[2]]] < scope &]

      prb = Select[m, #[[1]] != #[[2]] &]

      trans = Length[DeleteCases[Position[prb, Reverse[#]] & /@ prb, ]]/2

      1/3 (Length[m]/StringLength[uno] + Length[m]/StringLength[dos] + (
      Length[m] - trans)/Length[m])

      % // N


      Someone who can help me solve this problem? Maybe the approach I'm using is wrong, I hope someone is interested in this problem too. Thanks in advance







      list-manipulation function-construction programming string-manipulation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 18 at 23:05









      bullitohappy

      590217




      590217




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          6
          down vote



          accepted










          As an alternative you can use Experimental`JaroDistance:



          jD = Experimental`JaroDistance;
          jD[uno, dos]



          0.766667




          jD["JELLYFISH", "SMELLYFISH"]



          0.896296







          share|improve this answer




















          • thank you very much for the information has been very useful, since actually get the expected results, I did not know about that package, but I would like to performance my own version of that function, and check it with the option you proposed, I hope please You can help improve my programming attempt since you have more experience than me. Hoping to have your help, I say goodbye, wishing you an excellent day
            – bullitohappy
            Aug 20 at 5:22










          • Please, take a look at the solution proposed in the wolfram community, here is the link community.wolfram.com/groups/-/m/t/1416937 , I think it is very accurate, but I do not understand what the author of the answer is asking for, since he has already tried his function and fails, now I am trying to find the solution to the problem with the code he shared. Thanks for your help here on stack exchange, and vote for your answer
            – bullitohappy
            Aug 21 at 23:13










          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "387"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f180222%2fjaro-distance-in-mma%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          6
          down vote



          accepted










          As an alternative you can use Experimental`JaroDistance:



          jD = Experimental`JaroDistance;
          jD[uno, dos]



          0.766667




          jD["JELLYFISH", "SMELLYFISH"]



          0.896296







          share|improve this answer




















          • thank you very much for the information has been very useful, since actually get the expected results, I did not know about that package, but I would like to performance my own version of that function, and check it with the option you proposed, I hope please You can help improve my programming attempt since you have more experience than me. Hoping to have your help, I say goodbye, wishing you an excellent day
            – bullitohappy
            Aug 20 at 5:22










          • Please, take a look at the solution proposed in the wolfram community, here is the link community.wolfram.com/groups/-/m/t/1416937 , I think it is very accurate, but I do not understand what the author of the answer is asking for, since he has already tried his function and fails, now I am trying to find the solution to the problem with the code he shared. Thanks for your help here on stack exchange, and vote for your answer
            – bullitohappy
            Aug 21 at 23:13














          up vote
          6
          down vote



          accepted










          As an alternative you can use Experimental`JaroDistance:



          jD = Experimental`JaroDistance;
          jD[uno, dos]



          0.766667




          jD["JELLYFISH", "SMELLYFISH"]



          0.896296







          share|improve this answer




















          • thank you very much for the information has been very useful, since actually get the expected results, I did not know about that package, but I would like to performance my own version of that function, and check it with the option you proposed, I hope please You can help improve my programming attempt since you have more experience than me. Hoping to have your help, I say goodbye, wishing you an excellent day
            – bullitohappy
            Aug 20 at 5:22










          • Please, take a look at the solution proposed in the wolfram community, here is the link community.wolfram.com/groups/-/m/t/1416937 , I think it is very accurate, but I do not understand what the author of the answer is asking for, since he has already tried his function and fails, now I am trying to find the solution to the problem with the code he shared. Thanks for your help here on stack exchange, and vote for your answer
            – bullitohappy
            Aug 21 at 23:13












          up vote
          6
          down vote



          accepted







          up vote
          6
          down vote



          accepted






          As an alternative you can use Experimental`JaroDistance:



          jD = Experimental`JaroDistance;
          jD[uno, dos]



          0.766667




          jD["JELLYFISH", "SMELLYFISH"]



          0.896296







          share|improve this answer












          As an alternative you can use Experimental`JaroDistance:



          jD = Experimental`JaroDistance;
          jD[uno, dos]



          0.766667




          jD["JELLYFISH", "SMELLYFISH"]



          0.896296








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 18 at 23:20









          kglr

          161k8185384




          161k8185384











          • thank you very much for the information has been very useful, since actually get the expected results, I did not know about that package, but I would like to performance my own version of that function, and check it with the option you proposed, I hope please You can help improve my programming attempt since you have more experience than me. Hoping to have your help, I say goodbye, wishing you an excellent day
            – bullitohappy
            Aug 20 at 5:22










          • Please, take a look at the solution proposed in the wolfram community, here is the link community.wolfram.com/groups/-/m/t/1416937 , I think it is very accurate, but I do not understand what the author of the answer is asking for, since he has already tried his function and fails, now I am trying to find the solution to the problem with the code he shared. Thanks for your help here on stack exchange, and vote for your answer
            – bullitohappy
            Aug 21 at 23:13
















          • thank you very much for the information has been very useful, since actually get the expected results, I did not know about that package, but I would like to performance my own version of that function, and check it with the option you proposed, I hope please You can help improve my programming attempt since you have more experience than me. Hoping to have your help, I say goodbye, wishing you an excellent day
            – bullitohappy
            Aug 20 at 5:22










          • Please, take a look at the solution proposed in the wolfram community, here is the link community.wolfram.com/groups/-/m/t/1416937 , I think it is very accurate, but I do not understand what the author of the answer is asking for, since he has already tried his function and fails, now I am trying to find the solution to the problem with the code he shared. Thanks for your help here on stack exchange, and vote for your answer
            – bullitohappy
            Aug 21 at 23:13















          thank you very much for the information has been very useful, since actually get the expected results, I did not know about that package, but I would like to performance my own version of that function, and check it with the option you proposed, I hope please You can help improve my programming attempt since you have more experience than me. Hoping to have your help, I say goodbye, wishing you an excellent day
          – bullitohappy
          Aug 20 at 5:22




          thank you very much for the information has been very useful, since actually get the expected results, I did not know about that package, but I would like to performance my own version of that function, and check it with the option you proposed, I hope please You can help improve my programming attempt since you have more experience than me. Hoping to have your help, I say goodbye, wishing you an excellent day
          – bullitohappy
          Aug 20 at 5:22












          Please, take a look at the solution proposed in the wolfram community, here is the link community.wolfram.com/groups/-/m/t/1416937 , I think it is very accurate, but I do not understand what the author of the answer is asking for, since he has already tried his function and fails, now I am trying to find the solution to the problem with the code he shared. Thanks for your help here on stack exchange, and vote for your answer
          – bullitohappy
          Aug 21 at 23:13




          Please, take a look at the solution proposed in the wolfram community, here is the link community.wolfram.com/groups/-/m/t/1416937 , I think it is very accurate, but I do not understand what the author of the answer is asking for, since he has already tried his function and fails, now I am trying to find the solution to the problem with the code he shared. Thanks for your help here on stack exchange, and vote for your answer
          – bullitohappy
          Aug 21 at 23:13

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f180222%2fjaro-distance-in-mma%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)