in functions/source/publish-call-metadata/lambda_function.py [0:0]
def extract_phone_number_ctxt(transcript):
punc = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
for ele in punc:
if ele in punc:
transcript = transcript.replace(ele, '')
transcript = transcript.lower()
nospace = ''.join(i for i in transcript.split())
r1 = re.findall(r"[0-9]{8,10}", nospace)
context = [i.lower() for i in ['callbacknumber', 'callbackphonenumber', 'phonenumber', 'callback']]
if r1 != []:
for i in r1:
a = nospace.find(i)
seg = nospace[np.clip(a - 100, 0, len(nospace)):np.clip(a + 10, 0, len(nospace))]
key = list(filter(lambda x: x in seg, context))
if len(key) != 0:
ext = check_extension(nospace, i.strip())
if ext != False:
return ext
else:
return i.strip()
break
return ''
else:
return ''