How to use the danlp.datasets.EuroparlSentiment1 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_datasets.py View on Github external
def test_europarlsentiment1(self):
        eusent = EuroparlSentiment1()
        df = eusent.load_with_pandas()
        self.assertEqual(len(df), 184)
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)
github alexandrainst / danlp / examples / benchmarks / sentiment_benchmark.py View on Github external
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)
github alexandrainst / danlp / examples / benchmarks / sentiment_benchmark.py View on Github external
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)