def analyzeContactSegments()

in sam-app/lambda_functions/sfComprehendUtil.py [0:0]


def analyzeContactSegments(transcripts, compAnalysis, languageCode):
    
    comprehend = boto3.client(service_name='comprehend')
    rComprehend = {}

    for transcript in transcripts:
        if compAnalysis == "snt":
            rComprehend = detectSentiment(comprehend, transcript['content'], languageCode)
        elif compAnalysis == "kw":
            rComprehend = detectKeyWords(comprehend, transcript['content'], languageCode)
        elif compAnalysis == "dl":
            rComprehend = detectDominantLanguage(comprehend, transcript['content'])
        elif compAnalysis == "ne": 
            rComprehend = detectNamedEntities(comprehend, transcript['content'], languageCode)
        elif compAnalysis == "syn":
            rComprehend = detectSyntax(comprehend, transcript['content'], languageCode)
      
    return rComprehend