Coder Social home page Coder Social logo

learning-nlp's Introduction

自然语言处理算法与实战

本书主要是面向初学者,介绍了一些基础的入门知识和概念,同时提供一些偏向于实战的代码供给读者练习,这里是代码的主要介绍:

  • chapter-3 中文分词技术
  • chapter-4 词性标注与命名实体识别
  • chapter-5 关键词提取
  • chapter-6 句法分析
  • chapter-7 文本向量化
  • chapter-8 情感分析
  • chapter-9 NLP中用到的机器学习算法
  • chapter-10 基于深度学习的NLP算法

由于是初版,还存在不少小的问题,欢迎大家提issue,我们会积极地回复和改进,非常感谢大家。

learning-nlp's People

Contributors

liushuchun avatar sloth2012 avatar zhaoyuanfang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learning-nlp's Issues

第七章向量化算法 词袋模型,无法理解

稳重表述的是“词典中每个单词在文本中出现的频率”但是这个10维向量中应该不会出现0才对应为,另外按照数量来算的话,那么John出现了2次,而likes出现了3次,那么向量不应该是1,2开始的而是2,3开始,不知道我表述的对不对,或者可能我的理解有问题?

第二章数据未找到

2.3.3获取本地数据章节
书中原文“在Github的data目录下能下载到”,但是我并没有找到诶

chapter 5

第五章,tf-idf的算法直接调用jieba.analyse.extract_tags,和自己写的函数计算出来的结果不一致啊?这是为什么?谁更正确呢?

第七章 代码

word2vec_sim.py
image

应该这样:消除空格的
word = data[space_pos[i]+1:space_pos[i + 1]]

第九章,cluster报错

ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770

Code Error in Chapter 5

KeywordExtract.py:

#195 a += x1 * x1
=> a +=x1*x2

It may be basic, could still cause big trouble.
Please pay a little attention to the code work.
Thanks!

第三章中文分词-代码问题

位置:p42
问题1:__init__函数中maximum代表的是词典中最长词的长度,那是不是应该只保留最长词的长度,而不是每次读入一行都赋值,将self.maximum = len(line)改为self.maximum = max(self.maximum , len(line))

问题2:cut函数的while循环中,在if word is None:中除了要考虑一个字为词的索引移动以外,还应该把该字加入到result中,应该改为

if word is None:
    index -= 1
    result.append(text[index])

以上为个人见解,谢谢。

第8章运行出现问题!

Key rnn/basic_lstm_cell/bias not found in checkpoint
而且代码和书中有些差别,是不是这个版本是直接调models里面的。

第三章HMM中的viterbi的max函数

当需要分词的是一个文本段落时,viterbi函数中的max函数报错

Traceback (most recent call last):
File "D:\code\python_test\test\start.py", line 11, in
print(str(list(res)))
File "D:\code\python_test\test\hmm.py", line 150, in cut
prob, pos_list = self.viterbi(text, self.state_list, self.Pi_dic, self.A_dic, self.B_dic)
File "D:\code\python_test\test\hmm.py", line 134, in viterbi
for y0 in states if V[t - 1][y0] > 0])
ValueError: max() arg is an empty sequence

第七章 doc2vec复现相似度结果 0.64,没有书中的0.87

数据:
1.模型:用的是书中作者提供的训练好的模型文件,百度网盘下载的。
2.测试数据:用的同样的
3.代码:直接用的GitHub的
请问是我哪些细节我没有注意到吗?谢谢!

还有一个疑问:书中doc2vec训练代码 size = 200,而GitHub下载的代码中 size = 192,请问这个是有什么区别吗?
谢谢!

chapter3 分词代码有问题

分词的代码的初构函数有问题,词典词的最大长度应该判断一下再改变,原本的代码把每一个词的长度都赋值给了词典的词的最大长度了。

第四章实战1:日期识别 建议修改

我使用的是python3.6版本

1、原代码结果

text1 = '我要住到明天下午三点'
print(text1, time_extract(text1), sep=':')

text2 = '预定28号的房间'
print(text2, time_extract(text2), sep=':')

text3 = '我要从26号下午4点住到11月2号'
print(text3, time_extract(text3), sep=':')

text4 = '我要预订今天到30的房间'
print(text4, time_extract(text4), sep=':')

text5 = '今天30号呵呵'
print(text5, time_extract(text5), sep=':')

image
修改:
word = (datetime.today() + timedelta(days=keyDate.get(k, 0))).strftime('%Y{0}%m{1}%d{2}').format('年','月','日')

2、日期问题

image
建议直接去掉 parse_datetime函数 的try except,直接用except的内容
image

求书中第二章数据

你好,
书中第二章'NLP前置技术解析' 2.3.3中测试用到的数据 (如:house-prices.scv)能否提供下?
谢谢!

第六章中文编码问题

PCFG.py 在window环境下运行报错'utf-8' codec can't decode byte 0xb4 in position 0: invalid start byte,网上说的转换文件编码什么的都试过了,还是报一样的错,请问有什么解决办法吗

第九章笔误

9.3.2逻辑回归
第一段说它的优点是不容易过拟合,然后在最后一段又说它的缺点是容易过拟合......
这个笔误有点太明显啊

更简洁的IMM

# 更加简洁(more pythonic)的IMM算法(可用OOP)

_dictionary = {'南京', '南京市', '南京市长', '市长', '长江', '长江大桥', '江大桥', '大桥', '桥'}

def imm(text, maxlen=4):
    # inverse maximum matching method
    dictionary = _dictionary
    result = []
    index = len(text)
    while index > 0:
        m = min((index, maxlen))
        # dictionary = {e for e in _dictionary if e.endswith(text[index-1])}  # for speeding up
        for size in range(m, 0, -1):
            piece = text[(index-size):index]
            if piece in dictionary:
                result.insert(0, piece)
                index -= size
                break
        else:
            index -= 1
    return result

result = imm('南京市长江大桥')
print(result)

第7章doc2vec_sim装入模型文件报错

在doc2vec_sim.py这个文件中一运行到 model = g.Doc2Vec.load(model_path),就报错。
具体报错信息:_pickle.unpickingError:invalid load key '\xca'
报错环境:
Linux-4,15-1032-x86_64-with-debian-stretch-sid
GCC 5.4.0 20160609
python3.6.5
gensim=3.7.3
numpy=1.15.1
scipy=1.1.0
FAST_VERSION 1

第7章的数据

尊敬的作者,能否把第7章的数据放到某个百度网盘,供我们下载,原网站下载太慢了,最好能提供完整的代码。总是缺一些文件?非常感谢!

第5️章笔误

P96 安装 Gensim 的命令行代码应为 :

pip install gensim

原处写成了 genism

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.