Can someone help me with my string similarity thing

so I’m trying to make a string similarity app but instead of saying something like 50 or 87.639174, it says +infinity.

how it works is basically, that it first sees if one of the two strings are empty make it either 0 or 100 depending on the situation but it works completely fine, already tested it.

then, it splits the two strings by character to a list with each item being a character or letter, after that it does a for each starting at 1, ending at whatever is bigger the first string or the second, and goes up by 1.

inside the for each if both of the letters it’s in are the same it adds an item to the li list, by the way the true that is added to the list can be any item I just made it true to match the if else, and if the letters it’s in are not the same it adds an item to the il list, also remember li and il are different lists.

finally, it creates the percentage of the similarity of the two textboxes by dividing the amount of items in both lists and multiplying the result to get the percentage of similarity.

Instead of adding true or false to a single list li, keep two counters MATCHES and MISSES, and add 1 to MATCHES or MISSES depending on the match result.

Then take the ratio MATCHES / (MATCHES+MISSES) to get the success rate, and multiply that by 100 to get the per cent.

By the way, there is an algorithm called Levenshtein Distance worth a read.

Your li list will always have constant length of list the way you are doing it.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.