用Python进行自然语言处理 读书笔记 第一章

本文是《用Python进行自然语言处理》第一章的读书笔记,涵盖了文本搜索、词汇计数、基本编程概念、统计分布分析以及NLP的基础,如词意消歧和指代消解,探讨了自动理解自然语言的挑战和局限性。

用Python进行自然语言处理(第一章)

搜索文本

  
  text1.concordance("monstrous")#搜索文章中的词语
  text3.concordance("lived")
  text1.similar("monstrous")#近义词
  text2.common_contexts(["monstrous","very"])#两个词共同的上下文
  text4.dispersion_plot(['citizens','democracy','freedom','duties','America'])#该函数需要依赖numpy和matplotlib库

计数词汇

  set(text3)#text3中所有标点,单词的集合,去重
  sorted(set(text3))#text3中的所有标点、单词排序之后,去重
  len(set(text3))#text3的独一无二的标点、单词类型个数,称为唯一项目类型
  print(len(text3) / len(set(text3)))#每个字平均被使用的次数
  print(text3.count("smote"))#统计一个词语在一个文本中出现的次数
  print(100 * text4.count('a') / len(text4))#'统计一个词语占全部词语的百分比是多少

函数

  def关键字定义,lexical_diversity为函数名,text为参数
  def lexical_diversity(text):
      return len(text) / len(set(text))
  print(lexical_diversity(text3));
  def percentage(count, total):
      return  100 * count / total

将文本当作词链表

  a = ['Call','me','Ishmael','.']
  print(a[1])#索引是从0开始的
  print(text4[173]);#找到索引处的元素
  print(text4.index('awaken'));#找到元素第一次出现的索引
  print(text5[16715:16735])#获取链表中任意片段中的元素
  
  sent = ['word1','word2','word3','word4','word5','word6','word7','word8','word9','word10'];
  print(sent[5:8])#sent[m:n] m:n-1 m represents index
  print(
by Sumit Raj Apress 2019-02-04 192 pages Build your own chatbot using Python and open source tools. This book begins with an introduction to chatbots where you will gain vital information on their architecture. You will then dive straight into natural language processing with the natural language toolkit (NLTK) for building a custom language processing platform for your chatbot. With this foundation, you will take a look at different natural language processing techniques so that you can choose the right one for you. The next stage is to learn to build a chatbot using the API.ai platform and define its intents and entities. During this example, you will learn to enable communication with your bot and also take a look at key points of its integration and deployment. The final chapter of Building Chatbots with Python teaches you how to build, train, and deploy your very own chatbot. Using open source libraries and machine learning techniques you will learn to predict conditions for your bot and develop a conversational agent as a web application. Finally you will deploy your chatbot on your own server with AWS. What You Will Learn Gain the basics of natural language processing using Python Collect data and train your data for the chatbot Build your chatbot from scratch as a web app Integrate your chatbots with Facebook, Slack, and Telegram Deploy chatbots on your own server Who This Book Is For Intermediate Python developers who have no idea about chatbots. Developers with basic Python programming knowledge can also take advantage of the book.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值