I am trying to write a small python code,whereI am reading a text file-which contains both Multiwords (MWEs)and singular words (NMWEs). I am trying to tag each one, as follows.I have a dictionary of entries, containing the MWE and tagged MWE.I am tagging them as replace, and whichever I could not tag as MWE-the NMWE I am marking them so. I wrote the following codedef rule_disc():    corp=open(/python27/MWETagtext1.txt,r).read().lower()    print The Text file given Is:,corp    mwedict={'prime minister':'prime/MWE minister/MWE','new delhi':'new/MWE    delhi/MWE','reserve bank':'reserve/MWE bank/MWE'}    dict=mwedict    mwetag=reduce(lambda x, y: x.replace(y, dict[y]), dict, corp)    print MWE Tagged String Is:,mwetag    mwetagw=mwetag.split()    list1=[]    for word in mwetagw:        if / in word:            list1.append(word)        else:            word1=word+[NMWE]            list1.append(word1)    nlist=list1    nstring= .join(nlist)    print The Tagged Text File Is:,nstring on the given sample data, which is producing me the result. My question is, is there a smarter way to do it? Actual data size may run on millions of files. I am using Python2.7.12 on MS-Windows 7
Multiword Expression Tagging in Python
python;algorithm;python 2.7;machine learning;natural language processing