GithubHelp home page GithubHelp logo

文档太少了啊 about snownlp HOT 44 OPEN

isnowfy avatar isnowfy commented on June 2, 2024
文档太少了啊

from snownlp.

Comments (44)

moshuohua avatar moshuohua commented on June 2, 2024 1

你好,正在学习您的代码,关于自己训练情感分析的文件,按照你的文档里说的来做:

from snownlp.sentiment import Sentiment
sentiment = Sentiment()
sentiment.train('neg.txt','pos.txt')
sentiment.save('sentiment.marshal')

在_init_.py那里train()传入的参数是list?我也传入过list值
然后也会常常出现以下错误:

EOF read where object expected

自己捣鼓了好久也没有搞定,希望能帮助我一下~因为我以前收集了许多语料,想要丰富一下其他方面的情感分析的训练集。

非常感谢!

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

确实文档有点少,不过那个粗略的文档基本上涵盖了主要功能,目前程序还在不断修改,等写的稳定些了再补全文档吧。。。

from snownlp.

lemonhall avatar lemonhall commented on June 2, 2024

恩,我不太懂NLP,拿你这个简单做了一下豆瓣广播的情感分析,发觉效果不怎么好,看了一下代码,用得是贝叶斯和一套训练集,然后发觉可能是训练集本身让结果不是怎么好,又试了一下结合正文抽取算法,做了一下网页的keywords提取,结果发觉新浪的很多新闻,关键词抽取出来是单字,三字的人名没有被作为关键字抽取出来,作为黑箱的话,暂时还不是很好用的感觉,没有深入用,过两天用ZeroRPC替换掉你里面的分词组件,用我更熟悉的一个node.js的分词来试试,看看关键词抽取的效果会不会提高。

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

情感分析本来就是个很难的问题,貌似用bayes确实效果不是很好,后面考虑用svm替换掉,治愈关键词我自己的感觉还可以,或许你可以在https://github.com/isnowfy/snownlp/blob/master/snownlp/normal/stopwords.txt 自己加点stopwords,把没用的单字过滤掉可能会好一些吧

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

考虑了一下,估计也跟训练数据本身有关系,现在的数据都是买东西时的评价啥的。。。

from snownlp.

lemonhall avatar lemonhall commented on June 2, 2024

恩,所以对于外行来说。。。。你得多写一些文档,说明使用范围嘛,分词那部分我还没深究,什么CRF条件随机场这种东西我是看不懂的,我用的是node.js移植java社区的一个盘古分词组件,起码能正确的抽取去朝鲜金三胖的那位姑父的名字,其实很多关键字肯定是要优先抽取专有名词的。慢慢来,加油。。。我就是一个搞工程的,对这些复杂算法没能力搞,很遗憾。。很感谢你的这个组件。训练集什么的,看来得先自己写个插件慢慢攒了。。。而且这种东西,只能靠人工,且必须是滑动窗口法的。朋友给我介绍了情感分析的一个RNN算法的,考虑了句子的结构,原理上我懂,但是RNN谁懂啊,神经网络向来复杂,而且它那个的训练集也是22w的正向,20w的负能量,还带上了人工挑选的词汇分值表,内存消耗想必也挺可观的。你这个模块我在云端部署的时候,必须是1G内存,否则直接be killed。

工程上来说,不知道你的代码结构是怎样的,完成准确度和可靠度以及单元测试之后,再稍微考虑一下内存消耗以及可选加载这类的事情吧。。都是后话,中文的NLP库真心太少了。。。。让我们这些想做一些功能却不会算法的人觉得十分苦逼啊。尤其是看着NTK那类的库

多谢LZ

from snownlp.

asivy avatar asivy commented on June 2, 2024

你好
研究你写的代码 ,想问个弱弱的问题,在_init_.py中定义的类,怎样在外部其它文件中访问啊 ,我怎样import都不对

在 2013年12月16日 上午11:36,lemonhall [email protected]写道:

恩,所以对于外行来说。。。。你得多写一些文档,说明使用范围嘛,分词那部分我还没深究,什么CRF条件随机场这种东西我是看不懂的,我用的是node.js移植java社区的一个盘古分词组件,起码能正确的抽取去朝鲜金三胖的那位姑父的名字,其实很多关键字肯定是要优先抽取专有名词的。慢慢来,加油。。。我就是一个搞工程的,对这些复杂算法没能力搞,很遗憾。。很感谢你的这个组件。训练集什么的,看来得先自己写个插件慢慢攒了。。。而且这种东西,只能靠人工,且必须是滑动窗口法的。朋友给我介绍了情感分析的一个RNN算法的,考虑了句子的结构,原理上我懂,但是RNN谁懂啊,神经网络向来复杂,而且它那个的训练集也是22w的正向,20w的负能量,还带上了人工挑选的词汇分值表,内存消耗想必也挺可观的。你这个模块我在云端部署的时候,必须是1G内存,否则直接be
killed。

工程上来说,不知道你的代码结构是怎样的,完成准确度和可靠度以及单元测试之后,再稍微考虑一下内存消耗以及可选加载这类的事情吧。。都是后话,中文的NLP库真心太少了。。。。让我们这些想做一些功能却不会算法的人觉得十分苦逼啊。尤其是看着NTK那类的库

多谢LZ


Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-30631830
.

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@asivy 比如我在sentiment/init.py 定义的类Sentiment就直接 from snownlp.sentiment import Sentiment 就可以了

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@lemonhall 确实要想效果好的话,需要feature,数据集,model都要考虑好才行,所以现在代码还只能算雏形,慢慢改进吧,感谢提了这么多意见啊!
话说分词的话现在用的训练集是公开的人民日报1981年1月的那份,所以估计很多人名都没有,分出来确实比较困难,分词这个还需要增加更多的训练集才能达到更好的效果呢。

from snownlp.

asivy avatar asivy commented on June 2, 2024

[image: 内嵌图片 1] 我是用eclipse的pydev来开发python的
当我新建了一个snownlp工程后,在demo.py文件中怎么都引用不到_init_.py中的类SnowNLP

在 2013年12月16日 上午11:45,isnowfy [email protected]写道:

@lemonhall https://github.com/lemonhall确实要想效果好的话,需要feature,数据集,model都要考虑好才行,所以现在代码还只能算雏形,慢慢改进吧,感谢提了这么多意见啊!

话说分词的话现在用的训练集是公开的人民日报1981年1月的那份,所以估计很多人名都没有,分出来确实比较困难,分词这个还需要增加更多的训练集才能达到更好的效果呢。


Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-30632078
.

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@asivy 你可以把这个项目里的snownlp文件夹单独拿出来,然后放到和demo.py同一级,而不是这整个项目文件夹

from snownlp.

asivy avatar asivy commented on June 2, 2024

原来如此 搞定了 把snopnlp作为一个包而不是一个单独的工程

多谢了

在 2013年12月16日 下午12:11,isnowfy [email protected]写道:

@asivy https://github.com/asivy你可以把这个项目里的snownlp文件夹单独拿出来,然后放到和demo.py同一级,而不是这整个项目文件夹


Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-30632779
.

from snownlp.

asivy avatar asivy commented on June 2, 2024

还有一个问题想请教下,我主要在看python与自然语言处理这本书来学习NLP,但进展的有点已是,希望大牛可以推荐下其它的资料结合来学习。

在 2013年12月16日 下午12:47,Yazhou Wang [email protected]写道:

原来如此 搞定了 把snopnlp作为一个包而不是一个单独的工程

多谢了

在 2013年12月16日 下午12:11,isnowfy [email protected]写道:

@asivy https://github.com/asivy你可以把这个项目里的snownlp文件夹单独拿出来,然后放到和demo.py同一级,而不是这整个项目文件夹


Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-30632779
.

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@asivy 可以看看这门课,讲的还挺多的 https://www.coursera.org/course/nlp

from snownlp.

petitchamp avatar petitchamp commented on June 2, 2024

额,python有一个著名的分词库叫结巴分词,还有c++的实现的
楼上再github上一搜就有

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@moshuohua 传入的是文件的内容而不是文件名,sentiment.train(codecs.open('neg.txt','r','utf-8').readlines(),codecs.open('pos.txt','r','utf-8').readlines())

from snownlp.

FendaZheng avatar FendaZheng commented on June 2, 2024

你好,想请问一下关于情感分析的训练数据,大概需要多少。p.s. 小白 谢谢

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@FendaZheng 这不好说,肯定越多越好,但是也跟数据集的质量,数据的来源,数据的内容都有关系,只能尝试了

from snownlp.

thylaco1eo avatar thylaco1eo commented on June 2, 2024

@isnowfy 如果想参与接下来的开发,可不可以先试着帮忙补全一些文档?

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@thylaco1eo 好啊,欢迎欢迎~

from snownlp.

yukiknight026 avatar yukiknight026 commented on June 2, 2024

你好,关于情感训练我想请教一下,目前情感训练能否做增量训练呢。比如我原来的语料库有10000条,训练完毕后,若想往里面再加入500条,目前就好像只能重新训练这10500条生成新的marshal文件才能让这500条起作用。
所以现在有办法做增量训练,即修改或更新原来的marshal文件而不是重新生成么?
非常感谢!

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@yukiknight026 现在还没有办法做增量都是全量训练,增量的话要适当改改代码

from snownlp.

yukiknight026 avatar yukiknight026 commented on June 2, 2024

@isnowfy 非常感谢哈,那我再研究学习下~

from snownlp.

muzi-8 avatar muzi-8 commented on June 2, 2024

刚刚接触nlp,我想知道如何测试你的tag程序,你的199801.txt应该是训练语库吧,如何进行测试呢?

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@muzi-8 测试可以参考这篇文章

from snownlp.

Trueflash avatar Trueflash commented on June 2, 2024

@isnowfy 大神运行 seg.py 时,显示
from ..utils.tnt import TnT
ValueError: Attempted relative import in non-package
求解如何解决(路径是没问题的,但是就是提示这个错误)

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@Trueflash python对于包里的调用有限制,所以最好不要这样用,用的时候可以按照readme里的说法去用,一定要用的话可以python -m snownlp.seg.seg这样

from snownlp.

Trueflash avatar Trueflash commented on June 2, 2024

@isnowfy 谢谢大神 我去看看python对于包里的调用的具体限制 再研究研究

from snownlp.

Trueflash avatar Trueflash commented on June 2, 2024

@isnowfy 大神 我使用ipython notebook在sentiment文件夹下 尝试去读取训练好的模型 出现错误
具体代码
import marshal
d = marshal.load(open('sentiment.marshal', 'rb'))
报错如下:

ValueError
Traceback (most recent call last)
in ()
----> 1 d = marshal.load(open('sentiment.marshal', 'rb'))

ValueError: bad marshal data (unknown type code)
求解: 如何处理

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@Trueflash 你用我代码里的读取方式,都用了gzip压缩了

from snownlp.

Trueflash avatar Trueflash commented on June 2, 2024

@isnowfy 谢谢大神

from snownlp.

Trueflash avatar Trueflash commented on June 2, 2024

@isnowfy 大神 我在训练生成新的分词模型时报错
大神 README.md中的
分词在snownlp/seg目录下

from snownlp import seg
seg.train('data.txt')
seg.save('seg.marshal')
我的
from snownlp import seg
seg.train('/usr/local/lib/python2.7/dist-packages/snownlp/seg/data.txt')
seg.save('seg.marshal1')
报错/usr/local/lib/python2.7/dist-packages/snownlp/seg/y09_2047.pyc in train(self, data)
     66             self.bi.add((('', 'BOS'), ('', 'BOS')), 1)
     67             self.uni.add(('', 'BOS'), 2)
---> 68             for word, tag in sentence:

ValueError: too many values to unpack
求解!!!

from snownlp.

Trueflash avatar Trueflash commented on June 2, 2024

@isnowfy 大神已找到问题=> 训练的字典 包含类似'//b'的标记造成的

from snownlp.

cjmmya avatar cjmmya commented on June 2, 2024

请问一下笔者,snownlp中情感分析的方法是采用的贝叶斯算法吗?我看了一下源码,个人觉得是,但我想请假一下大家。谢谢!

from snownlp.

cjmmya avatar cjmmya commented on June 2, 2024

请问一下笔者,snownlp中情感分析的方法是采用的贝叶斯算法吗?我看了一下源码,个人觉得是,但我想请假一下大家。谢谢!

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@cjmmya 用的是贝叶斯算法

from snownlp.

cjmmya avatar cjmmya commented on June 2, 2024

@isnowfy 谢谢您的答复!非常感激!最近我在做文本的情感分析,主要针对国内的微博文本,所以在看您的源码,想借鉴一下您的方法!

from snownlp.

superCoderLWT avatar superCoderLWT commented on June 2, 2024

您好@isnowfy ,看了你的文档我还是没有理解要怎么用你的代码进行文本分类,我最近在学习文本挖掘,所以希望借鉴一下您的方法。

from snownlp.

superCoderLWT avatar superCoderLWT commented on June 2, 2024

您其他的功能的接口在readme里面体现,好像就是除了文本分类没有

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@superCoderLWT 可以看一下情感分析那块的代码,就是直接调用的文本分类

from snownlp.

Yevgnen avatar Yevgnen commented on June 2, 2024

请问文档是只有readme吗?是不是只有一个接口SnowNLP('句子')?

from snownlp.

isnowfy avatar isnowfy commented on June 2, 2024

@Yevgnen 目前文档只有readme,所有接口都统一到那一个接口里

from snownlp.

zachary666233 avatar zachary666233 commented on June 2, 2024

你好。想请教一下可以把文本的情感褒贬值标记为0,0.2,0.4,0.6,0.8,1这样的形式去训练文本嘛

from snownlp.

NZbryan avatar NZbryan commented on June 2, 2024

代码很简洁,只看到了bayes模型,期待后期引入dl模型

from snownlp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.