GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — document_rating/positive_negative_split.py at master · abc3436645/document_rating

Expand file tree

/

positive_negative_split.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
64 lines (59 loc) · 2.46 KB
/

positive_negative_split.py

Copy path

File metadata and controls

64 lines (59 loc) · 2.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
__author__ = 'NLP-PC'
def get_pos_neg_va(corpus, lexicon, mark):
pos_valence_mean = []
neg_valence_mean = []
valence_true = []
pos_arousal_mean = []
neg_arousal_mean = []
arousal_true = []
def VA_mean(text):
pos_sum_valence = 1
neg_sum_valence = 1
pos_sum_arousal = 1
neg_sum_arousal = 1
pos_count_v = 0
neg_count_v = 0
pos_count_a = 0
neg_count_a = 0
avg = 5
for word in text:
for l in lexicon:
if word == l[0]:
# if l[1] > 9:
# l[1] = 9
# if l[1] < 1:
# l[1] = 1
# if l[2] > 9:
# l[2] = 9
# if l[2] < 1:
# l[2] = 1
if l[1] >= avg:
pos_count_v = pos_count_v + 1
pos_sum_valence = pos_sum_valence * l[1]
else:
neg_count_v = neg_count_v + 1
neg_sum_valence = neg_sum_valence * l[1]
if l[2] >= avg:
pos_count_a = pos_count_a + 1
pos_sum_arousal = pos_sum_arousal * l[1]
else:
neg_count_a = neg_count_a + 1
neg_sum_arousal = neg_sum_arousal * l[1]
pos_valence = (pos_sum_valence ** (1. / pos_count_v) if pos_count_v != 0 else avg)
neg_valence = (neg_sum_valence ** (1. / neg_count_v) if neg_count_v != 0 else avg)
pos_arousal = (pos_sum_arousal ** (1. / pos_count_a) if pos_count_a != 0 else avg)
neg_arousal = (neg_sum_arousal ** (1. / neg_count_a) if neg_count_a != 0 else avg)
return [pos_valence, neg_valence, pos_arousal, neg_arousal]
for (i, text) in enumerate(corpus):
pos_valence, neg_valence, pos_arousal, neg_arousal = VA_mean(text)
pos_valence_mean.append(pos_valence)
neg_valence_mean.append(neg_valence)
pos_arousal_mean.append(pos_arousal)
neg_arousal_mean.append(neg_arousal)
try:
ind = [item[0] for item in mark].index(i + 1)
except ValueError:
raise Exception('File not found. NO. %i' % (i + 1))
valence_true.append(mark[ind][1])
arousal_true.append(mark[ind][2])
return pos_valence_mean, neg_valence_mean, valence_true, pos_arousal_mean, neg_arousal_mean, arousal_true
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.