I want to know what is the best approach that can indicate for me the best match for text based on list of dictionaries. I have tried using any() but it didn’t work and I even tried to make a normal loop statement that goes through the loop and if value == text return text but it didn’t work as expected
data=[{
"categories":"application update",
"options":["application","update computer application","update computer application","update application computer"],
},
{
"categories":"computer information",
"options":["computer information","computer information","computer properties"],
},
{
"categories":"operating system",
"options":["operating system","update computer operating system","computer operating system"],
},
{
"categories":"adobe software",
"options":["adobe software issue","application adobe issue","fix my adobe application"],
},
]
text="computer update"
What i managed to do is this bvut it didnt work as expected
for i in data:
for j in i['options']:
if text== j:
print(i['categories'])
The above data variable include list of dic and im getting text and based on that text i try to best match text with most sutable category for example text ="update ope4rating system " then catgroies will be only operating system
for example text="fix adobe software" then catgory will be only adobe software
what im trying to achieve is to determine text will be related to which category . for example update computer will be operating system category and for example adobe software application issue related to adobe software
Thank you