Replace abbreviation or slang word in Indonesian

762 Views Asked by At

i have a lot of text data like this in excel files raw data

and a list of dictionary from slang or abbreviations word in Indonesia from txt files slang/abbreviation word

How to replace the word in the text based on the dictionary that i've made before?

1

There are 1 best solutions below

3
On

You can do it in this way (this an example for one string):

string = 'asd des sdss d'
replacements = {"asd": "replaced"}
new_string = " ".join(replacements.get(word, word) for word in string.split(' '))
print(new_string)

result: 'replaced des sdss d'

This does not take care of special characters in the text like ',' or '.'. Maybe you need to add logic to take care of these things.