Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_europarlsentiment1(self):
eusent = EuroparlSentiment1()
df = eusent.load_with_pandas()
self.assertEqual(len(df), 184)
def bert_sent_benchmark(datasets):
model = load_bert_tone_model()
for dataset in datasets:
if dataset == 'euparlsent':
data = EuroparlSentiment1()
if dataset == 'lccsent':
data = LccSentiment()
df = data.load_with_pandas()
df['valence'] = df['valence'].map(to_label)
# predict with bert sentiment
df['pred'] = df.text.map(lambda x: model.predict(x, analytic=False)['polarity'])
report(df['valence'], df['pred'], 'BERT_Tone (polarity)', dataset)
urllib.request.urlretrieve(url+file, workdir+'/'+file)
sys.path.insert(1, workdir)
os.chdir(workdir+ '/')
sys.stdout = open(os.devnull, 'w')
from SentidaV2 import sentidaV2
sys.stdout = sys.__stdout__
def sentida_score(sent):
return sentidaV2(sent, output ='total')
for dataset in datasets:
if dataset == 'euparlsent':
data = EuroparlSentiment1()
if dataset == 'lccsent':
data = LccSentiment()
df = data.load_with_pandas()
df['pred'] = df.text.map(sentida_score).map(to_label_sentida)
df['valence'] = df['valence'].map(to_label)
report(df['valence'], df['pred'], 'SentidaV2', dataset)
def afinn_benchmark(datasets):
afinn = Afinn(language='da', emoticons=True)
for dataset in datasets:
if dataset == 'euparlsent':
data = EuroparlSentiment1()
if dataset == 'lccsent':
data = LccSentiment()
df = data.load_with_pandas()
df['pred'] = df.text.map(afinn.score).map(to_label)
df['valence'] = df['valence'].map(to_label)
report(df['valence'], df['pred'], 'Afinn', dataset)