How to use the danlp.models.load_bert_tone_model function in danlp

To help you get started, we’ve selected a few danlp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexandrainst / danlp / tests / test_bert_models.py View on Github external
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'})
github alexandrainst / danlp / examples / benchmarks / sentiment_benchmark.py View on Github external
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)