если токен предшествует или предшествует определенному слову - PullRequest
0 голосов
/ 09 марта 2020
txt = " the #3 flight attendant has done a good job. the flight attendant #1 has helped flight \ 
attendant#3"
txt = re.sub('(?<=\w)([!#,])', r' \1', txt) ## Added a space before #
txt = ' '.join(txt.split()) ## Remove multiple white space
txt_list_tok = txt.split()
txt_list_tok

Как я могу заменить консультативные 3 токена, такие как «# 3», «рейс», «сопровождающий» или «рейс», «сопровождающий», «№ 3» на «ПОЛЕТ», «АТТЕНДАНТ» в python 3,6

...