LookupError: Resource omw-1.4 not found. nltk3.7查找近反义词解决方法

在运用nltk3.7查找同近义词时,发现自己运行代码后会报错:

LookupError: Resource omw-1.4 not found.

这里解决方式很简单:只需要加一行即可。

import nltk
nltk.download('omw-1.4')

Linux和Windows通用。

所以代码可以参考下面链接,在代码前面加上这一个字段即可

使用nltk库查找英文同义词和反义词_梧桐雪的博客-CSDN博客_nltk 同义词

这里只展示同义词代码:

from nltk.corpus import wordnet
import nltk
nltk.download('omw-1.4')
word = "fight"
synonyms = []

for syn in wordnet.synsets(word):
    for lm in syn.lemmas():
        synonyms.append(lm.name())
print (set(synonyms))

第二次运行时可以把download注释掉。

运行结果:

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Build cool NLP and machine learning applications using NLTK and other Python libraries About This Book Extract information from unstructured data using NLTK to solve NLP problems Analyse linguistic structures in text and learn the concept of semantic analysis and parsing Learn text analysis, text mining, and web crawling in a simplified manner Who This Book Is For If you are an NLP or machine learning enthusiast with some or no experience in text processing, then this book is for you. This book is also ideal for expert Python programmers who want to learn NLTK quickly. What You Will Learn Get a glimpse of the complexity of natural languages and how they are processed by machines Clean and wrangle text using tokenization and chunking to help you better process data Explore the different types of tags available and learn how to tag sentences Create a customized parser and tokenizer to suit your needs Build a real-life application with features such as spell correction, search, machine translation and a question answering system Retrieve any data content using crawling and scraping Perform feature extraction and selection, and build a classification system on different pieces of texts Use various other Python libraries such as pandas, scikit-learn, matplotlib, and gensim Analyse social media sites to discover trending topics and perform sentiment analysis In Detail Natural Language Processing (NLP) is the field of artificial intelligence and computational linguistics that deals with the interactions between computers and human languages. With the instances of human-computer interaction increasing, it's becoming imperative for computers to comprehend all major natural languages. Natural Language Toolkit (NLTK) is one such powerful and robust tool. You start with an introduction to get the gist of how to build systems around NLP. We then move on to explore data science-related tasks, following which you will learn how to create a customized tokenizer and parser from scratch. Throughout, we delve into the essential concepts of NLP while gaining practical insights into various open source tools and libraries available in Python for NLP. You will then learn how to analyze social media sites to discover trending topics and perform sentiment analysis. Finally, you will see tools which will help you deal with large scale text. By the end of this book, you will be confident about NLP and data science concepts and know how to apply them in your day-to-day work. Table of Contents Chapter 1: Introduction to Natural Language Processing Chapter 2: Text Wrangling and Cleansing Chapter 3: Part of Speech Tagging Chapter 4: Parsing Structure in Text Chapter 5: NLP Applications Chapter 6: Text Classification Chapter 7: Web Crawling Chapter 8: Using NLTK with other Python Libraries Chapter 9: Social Media Mining in Python Chapter 10: Text Mining at Scale
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值