gpt4 book ai didi

stanford-nlp - 斯坦福NLP训练情感模型

转载 作者:行者123 更新时间:2023-12-04 18:40:23 26 4
gpt4 key购买 nike

我正在参加 Rotten Tomatoes NLP 预测的 kaggle 竞赛。

训练集格式解析如下:

PhraseId SentenceId Phrase Sentiment

1 1 A series of escapades demonstrating the adage that what is good for the goose is also good for the gander , some of which occasionally amuses but none of which amounts to much of a story . 1

2 1 A series of escapades demonstrating the adage that what is good for the goose 2

但是,训练集公式必须如下所示:

(3 (2 (2 The) (2 Rock)) (4 (3 (2 is) (4 (2 destined) (2 (2 (2 (2 (2 to) (2 (2 be) (2 (2 the) (2 (2 21st) (2 (2 (2 Century) (2 's)) (2 (3 new) (2 (2 ``) (2 Conan)))))))) (2 '')) (2 and)) (3 (2 that) (3 (2 he) (3 (2 's) (3 (2 going) (3 (2 to) (4 (3 (2 make) (3 (3 (2 a) (3 splash)) (2 (2 even) (3 greater)))) (2 (2 than) (2 (2 (2 (2 (1 (2 Arnold) (2 Schwarzenegger)) (2 ,)) (2 (2 Jean-Claud) (2 (2 Van) (2 Damme)))) (2 or)) (2 (2 Steven) (2 Segal))))))))))))) (2 .)))

这是我正在使用的 python 代码片段:

  phrasefind=str(train['Phrase'][i])+" " or " "+str(train['Phrase'][i]) or str(train['Phrase'][i])
phrase=train['Phrase'][i]
sent=rreplace(sent,phrasefind,"("+str(train['Sentiment'][i])+" "+str(phrase)+") ",1)

结果:

(1 (2 (2 (2 A) series) of (2 escapades) (2 (2 demonstrating) the adage) (2 that) (2 what) is good for the goose) (2 is) (2 also) (3 good) (2 for) (2 the) (2 gander) (2 ,) (2 (2 some) of which) (2 occasionally) (3 amuses) (2 but) (2 none) (2 of which) (2 amounts) (2 to) (2 much) (2 of) (2 a story) .)

但是,斯坦福的情绪包无法识别这种格式(适用于他们的 train.txt)
它抛出错误:

Exception in thread "main" java.lang.NumberFormatException: null

建议?

最佳答案

我目前正在学习如何自己训练模型。

查看您的 train.txt 问题在于您没有对某些单词进行评分。我刚刚对您的结果进行了这些更改,并且命令行已成功将其添加到我的模型中:

(1 (2 (2 (2 A) series) (2 of) (2 escapades) (2 (2 demonstrating) (2 the) (2     adage)) (2 that) (2 what) (2 is) (3 good) (2 for) (2 the) (2 goose) (2 is) (2 also) (3 good) (2 for) (2 the) (2 gander) (2 ,) (2 (2 some) (2 of) (2 which)) (2 occasionally) (3 amuses) (2 but) (2 none) (2 of which) (2 amounts) (2 to) (2 much) (2 of) (2 a story) (2 .))

关于stanford-nlp - 斯坦福NLP训练情感模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24416785/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com