I'm trying to remove email names from transcripts because it removes unnecessary info that is not needed in the transcript.
The regex below removes email names from a spoken transcript.
Examples below are completely made up. You'll note above that "dot" and "at" are the only common terms.
Format:
- token1 tokenN at word dot word
- before "at" remove 1-2 tokens delimited by spaces
- remove "at"
- remove the word after "at"
- remove "dot"
- remove the word after "dot"
Given the above at least the email name would be mostly removed. Prior to "at" you don't know how many words make up the email name or are part of the text.
The regex I created covers all cases above and leaves some words remaining in long email names:
import re
regExpattern = "[a-zA-Z0-9_.+-]+\s*at\s*[a-zA-Z0-9-.]+\s*[a-zA-Z0-9-]*\s*dot*\s*[a-zA-Z0-9-]{3}"
emails = ["jane 94 at g mail dot com",
"9 at gmail dot com",
"jim doe at gmail dot com",
"I am jane doe at A.B. dot com",
"I am jane at AB dot com",
"just email happy jane doe seventy three at msn dot com",
"jane doe seven to seven at hotmail dot com"
]
for text in emails:
cleanText = re.sub(regExpattern, '', text)
print(cleanText)
You can try it here: https://regex101.com/r/XV5GMT/2
Q: What spoken email names does the regex above miss (other than what I mention above)? Also, an email name that is mostly removed is good enough.
Alternatively, I tried to use POS tagging but couldn't discern any consistent patterns.
[email protected]
, which I presume would be transcribed asFirstname dot lastname at example dot com
. Or at least it is missing that testcase. \$\endgroup\$