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_predictions(self):
model = load_bert_tone_model()
self.assertEqual(model.predict('han er 12 Γ₯r', polarity=False),{'analytic': 'objective', 'polarity': None})
self.assertEqual(model.predict('han gΓΈr det godt', analytic=False),{'analytic': None, 'polarity': 'positive'})
self.assertEqual(model.predict('Det er super dΓ₯rligt'),{'analytic': 'subjective', 'polarity': 'negative'})
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)