Beispiel #1
0
 def __call__(self, files=None, verbose=True):
     if verbose:
         print(f'\nProcessing files...')
         print(f'\nProcessing sentiment...')
     SentimentAnalysis.__call__(self, files=files)
     if verbose:
         print(f'\nProcessing opinion fact...')
     FactOpinion.__call__(self, files=files)
     gc.collect()
     if verbose:
         print('\nDone !')
Beispiel #2
0
                   sep=';',
                   error_bad_lines=False)

countNegative = 0
countPositive = 0
countNetural = 0

df1 = data['text']

with open('visitor/Pier21winter/out2013Pier21vistorwinter.csv',
          'w') as outfile:
    writer = csv.writer(outfile)
    writer.writerow(["text", "Sentiment", "Score"])

    for row in df1.iteritems():
        s = SentimentAnalysis(filename='SentiWordNet.txt',
                              weighting='geometric')
        textt = row[1]
        if s.score(textt) == 0.0:
            senti = "netural"
            countNetural = countNetural + 1

        if s.score(textt) < 0.0:
            senti = "negative"
            countNegative = countNegative + 1
        if s.score(textt) > 0.0:
            senti = "positive"
            countPositive = countPositive + 1
        writer.writerow(
            [textt.encode('unicode-escape'), senti,
             s.score(textt)])
    writer.writerow([countNetural, countNegative, countPositive])
Beispiel #3
0
    def test_get_sentiment_socre_english(self):
        text = "Happiness is unreachable thing. Because it's impossible."
        analyzedResult = SentimentAnalysis(text)
        analyzedResult.analyze()

        print(analyzedResult.get_sadness_score())
        print(analyzedResult.get_anger_score())
        print(analyzedResult.get_anxiety_score())
        # print(analyzedResult.get_agony_score())
        print(analyzedResult.get_embarrassed_score())
        print(analyzedResult.get_happiness_score())
        print(analyzedResult.get_total_score())

        print(analyzedResult.get_positive_score())
        print(analyzedResult.get_neutral_score())
        print(analyzedResult.get_negative_score())
Beispiel #4
0
    def test_get_sentiment_score(self):
        text = "너무나 우울해서 미칠 것만 같다. 나는 왜 이러는 것일까"
        analyzedResult = SentimentAnalysis(text)
        analyzedResult.analyze()

        print(analyzedResult.get_sadness_score())
        print(analyzedResult.get_anger_score())
        print(analyzedResult.get_anxiety_score())
        print(analyzedResult.get_agony_score())
        print(analyzedResult.get_embarrassed_score())
        print(analyzedResult.get_happiness_score())
        print(analyzedResult.get_total_score())

        print(analyzedResult.get_positive_score())
        print(analyzedResult.get_negative_score())
Beispiel #5
0
def get_sentiment_analysis():
    if not sa:
        sa = SentimentAnalysis()

    return sa
Beispiel #6
0
data = pd.read_csv('visitor/HalifaxHarboursummer/2016HalifaxHarbourvistorsummer.csv', sep=';', error_bad_lines=False)

countNegative=0
countPositive=0
countNetural=0


df1 = data['text']

with open('visitor/HalifaxHarboursummer/out2016HalifaxHarbourvistorsummer.csv', 'w') as outfile:
    writer = csv.writer(outfile)
    writer.writerow(["text","Sentiment","Score"])

    for row in df1.iteritems():
        s = SentimentAnalysis(filename='SentiWordNet.txt', weighting='geometric')
        textt = row[1]
        if s.score(textt)==0.0:
                senti="netural"
                countNetural=countNetural+1

        if s.score(textt)<0.0:
                senti = "negative"
                countNegative=countNegative+1
        if s.score(textt) > 0.0:
                senti = "positive"
                countPositive=countPositive+1
        writer.writerow(
                [textt.encode('unicode-escape'),senti, s.score(textt)])
    writer.writerow([countNetural, countNegative, countPositive])
Beispiel #7
0
 def __init__(self, main_dir):
     FactOpinion.__init__(self, main_dir)
     SentimentAnalysis.__init__(self, main_dir)
     self.head = self.columns + list(self.entity_dict.keys()) + list(
         self.tag_dict.keys()) + list(self.dep_dict.keys())