Skip to content Skip to sidebar Skip to footer

Text Processing And Detection From A Specific Dictionary In Python

I have a text in English that I want to process to detect specific entries that I have in another dictionary in Python (example entry: mass spectroscopy). Those entries are very im

Solution 1:

if i didn't misunderstand you, you want to check the dictionary items with the list items. Then print the results to the console.

dict_1={"Liquid Biopsy":"Blood for analysis","cfDNA":"Blood for analysis","Liquid Biopsies":"Blood for analysis"}
list_1=[u'Liquid', u'biopsies', u'based', u'on', u'circulating', u'cell-free', u'DNA', u'(cfDNA)', u'analysis', u'are', u'described', u'as', u'surrogate', u'samples', u'for', u'molecular', u'analysis.']
string_1=" ".join(list_1).lower()
for i in dict_1:
    if i.lower() in string_1:
        print("Key: {}\nValue: {}\n".format(i,dict_1[i]))

I used the above codes and the console printed the below results.

Key: Liquid Biopsies
Value: Blood for analysis

Key: cfDNA
Value: Blood for analysis


Process finished withexit code 0

Post a Comment for "Text Processing And Detection From A Specific Dictionary In Python"