How to get closet of a string

Hi,
@ClaytonM , @vvaidya , @aksh1yadav ,
I looked into the forum , but i didn’t get the desired result. Matching a string based on similarity i.e. not exact match

Few example foe the scenario-

List of word-

EMEC CT - DOCUMENTATION
EMEC CT - IMPLEMENTATION
EMEC CT - INSTALLATION ASSISTANCE
EMEC CT - PRJ MANAGEMENT
EMEC CT - PRJ MANAGEMENT
EMEC CT - QUALITY ASSURANCE
EMEC CT - SCOPING AND INVESTIGATION
EMEC CT - TESTING
EMEC CT - TRAINING

From these kind of word , when bot will run it need to pick the closest match.
(Challenge 1.here is we can’t extract all the list of word , present in web application
2.To get to other word from list we need to scroll down, so in single shot bot has pick the closest of name)

Say example - We can have input word as EMEC CT - INSTALLATION ASS or EMEC CT - INSTALLATION or EMEC CT - INSTALLATION ASSISTANCE MANAGER ETC.
Like this combination can occur…

Can this be automated?
Or is there any work around?

Ahtesham

By observing the list of words the first word after hiphen (-) is unique. So from your input word consider only one word after hiphen and search in the list of words.

Regards,
Karthik Byggari

If there’s a will, there’s a way!

From my understanding, you simply want to check “does the item from the list contain the input word” OR “does the input word contain the item from the list”, then select that item. So the only real challenge is getting the list of words so you can make that comparison.

It’s difficult to know for sure how your application works without working with it. However, in general, if the items are found inside a list box (like with a scrollbar), you can use Get Attribute to get the inner text, the value, or the items. The first thing I would try is creating an array of string variable and using it in the Get Attribute activity with “items” as the attribute (you can verify by outputting the result in a Write Line like variable.Count.ToString or String.Join(“,”,variable) ). I don’t know if that will work though, so you might try other attributes. If push comes to shove, you could just get the innertext or use Get Text activity, and use string manipulation to get your list (like split by newline character) and store to that array variable. I don’t know the definite solution to this part.

Once you have that list, then you can query it to the item that is closest using a string .Contains() comparison going both ways as I previously pointed out.
This might look like:
selectionMatches = listOfItems.Where(Function(x) x.ToUpper.Contains(inputValue.ToUpper) Or inputValue.ToUpper.Contains(x.ToUpper)

Then check that new array to make sure you found a match:

IF selectionMatches.Count > 0
    Select Item // use selectionMatches(0) to pick the first item that was a match

I hope this helps.

Regards.

You can use the Python “difflib” library’s “get_close_matches” function.