Пример #1
0
def get_text_sentiment(text):
    alchemy_api_key = "ce6d4fd632e66e75542c39f00d5408962ac58697"
    alchemy_language = AlchemyLanguage(api_key=alchemy_api_key)
    result = alchemy_language.sentiment(text=text)
    if result['docSentiment']['type'] == 'neutral':
        return 'netural', 0
    return result['docSentiment']['type'], result['docSentiment']['score']
Пример #2
0
def get_text_sentiment(text):
    alchemy_api_key = os.environ.get("ALCHEMY_API_KEY")
    
    alchemy_language = AlchemyLanguage(api_key=alchemy_api_key)
    result = alchemy_language.sentiment(text=text)
    if result['docSentiment']['type'] == 'neutral':
        return 'netural', 0
    return result['docSentiment']['type'], result['docSentiment']['score']
Пример #3
0
def get_text_sentiment(text):
    alchemy_api_key = os.environ.get("ALCHEMY_API_KEY")

    alchemy_language = AlchemyLanguage(api_key=alchemy_api_key)
    result = alchemy_language.sentiment(text=text)
    if result['docSentiment']['type'] == 'neutral':
        return 'netural', 0
    return result['docSentiment']['type'], result['docSentiment']['score']
Пример #4
0
def get_text_sentiment(text):
    #return a dictionary containing text sentiment and values
    alchemy_api_key = config.ALCHEMY_API_KEY
    alchemy_language = AlchemyLanguage(api_key=alchemy_api_key)
    result = alchemy_language.sentiment(text=text)

    #Uncomment to see FULL json output
    #print str(result)
    #print (result['docSentiment'])
    return result['docSentiment']
Пример #5
0
 def get_text_sentiment(text):
     alchemy_language = AlchemyLanguage(api_key=self.alchemytoken)
     result = alchemy_language.sentiment(text=text)
     if result[‘docSentiment’][‘type’] == ‘neutral’:
         return ‘netural’, 0