Skip to main content

Tuples in Python

 A tuple is an assortment of items which requested and permanent. Tuples are successions, very much like records. The contrasts among tuples and records are, the tuples can't be changed not normal for records and tuples use enclosures, though records utilize square sections.  Making a tuple is pretty much as straightforward as putting diverse comma-isolated qualities. Alternatively you can put these comma-isolated qualities between enclosures moreover. For instance −  tup1 = ('material science', 'science', 1997, 2000);  tup2 = (1, 2, 3, 4, 5 );  tup3 = "a", "b", "c", "d";  The void tuple is composed as two enclosures containing nothing −  tup1 = ();  To compose a tuple containing a solitary worth you need to incorporate a comma, despite the fact that there is just one worth −  tup1 = (50,);  Like string files, tuple records start at 0, and they can be cut, linked, etc.  Getting to Values in Tuples  To get to values in tuple, u...

Python - WordNet Interface

WordNet is a word reference of English, like a conventional thesaurus NLTK incorporates the English WordNet. We can utilize it as a source of perspective for getting the significance of words, utilization model and definition. An assortment of comparable words is called lemmas. The words in WordNet are coordinated and hubs and edges where the hubs address the word text and the edges address the relations between the words. underneath we will perceive how we can utilize the WordNet module. 

All Lemmas 

from nltk.corpus import wordnet as wn 

res=wn.synset('locomotive.n.01').lemma_names() 

print res 

At the point when we run the above program, we get the accompanying yield − 

[u'locomotive', u'engine', u'locomotive_engine', u'railway_locomotive'] 

Word Definition 

The word reference meaning of a word can be gotten by utilizing the definition work. It portrays the significance of the word as we can discover in an ordinary word reference. 

from nltk.corpus import wordnet as wn 

resdef = wn.synset('ocean.n.01').definition() 

print resdef 

At the point when we run the above program, we get the accompanying yield − an enormous waterway establishing a key piece of the hydrosphere 

Read Our Latest Blog: Python Numbers

Use Examples 

We can get the model sentences showing some use instances of the words utilizing the exmaples() work. 

from nltk.corpus import wordnet as wn 

res_exm = wn.synset('good.n.01').examples() 

print res_exm 

At the point when we run the above program, we get the accompanying yield − 

['for your own great', "what's the benefit of worrying?"] 

Inverse Words 

Get All the contrary words by utilizing the antonym work. 

from nltk.corpus import wordnet as wn 

# get every one of the antonyms 

res_a = wn.lemma('horizontal.a.01.horizontal').antonyms() 

print res_a 

At the point when we run the above program we get the accompanying yield − 

[Lemma('inclined.a.02.inclined'), Lemma('vertical.a.01.vertical')]


Read Full Article Here: Python - WordNet Interface

Comments

Popular posts from this blog

Tuples in Python

 A tuple is an assortment of items which requested and permanent. Tuples are successions, very much like records. The contrasts among tuples and records are, the tuples can't be changed not normal for records and tuples use enclosures, though records utilize square sections.  Making a tuple is pretty much as straightforward as putting diverse comma-isolated qualities. Alternatively you can put these comma-isolated qualities between enclosures moreover. For instance −  tup1 = ('material science', 'science', 1997, 2000);  tup2 = (1, 2, 3, 4, 5 );  tup3 = "a", "b", "c", "d";  The void tuple is composed as two enclosures containing nothing −  tup1 = ();  To compose a tuple containing a solitary worth you need to incorporate a comma, despite the fact that there is just one worth −  tup1 = (50,);  Like string files, tuple records start at 0, and they can be cut, linked, etc.  Getting to Values in Tuples  To get to values in tuple, u...

Python Numbers: A Detailed Guide

 You don't be a human calculator to program well. Not many developers need to know more than essential variable-based math. How much numerical you need to know relies upon the application you're chipping away at. As a general rule, the degree of math needed to be a software engineer is lower than you may anticipate. Even though math and PC writing computer programs aren't just about as connected as certain individuals may accept, numbers are a necessary piece of any programming language, and Python is no exemption.  In this exercise, you'll figure out how to:  Make numbers and gliding point numbers  Round numbers to a given number of decimal spots  Organization and show numbers in strings  We should begin!  Note: This instructional exercise is adjusted from the section "Numbers and Math" in Python Basics: A Practical Introduction to Python 3.  The book utilizes Python's implicit IDLE manager to make and alter Python records and interface with the ...

What Is The Use Of Artificial Intelligence In Future?

  Artificial Intelligence is definitely the future of the world. Artificial Intelligence will drive the economy of tomorrow. Are you excited about   Artificial Intelligence?   Google, Facebook, Apple, Microsoft are all moving ahead at great speed in improving this Artificial Intelligence. So, it’s very exciting! Software is going to solve that where it’ll look at the new information and present to you knowing about your interests what would be most valuable. So: making us more efficient. We’re focusing on autonomous systems and we sort of see it has the mother of all AI projects. Areas where Artificial Intelligence is going to impact our future lives. Autonomous Transportation:   As the companies like Uber, Google & General Motors are struggling hard to establish themselves at the top of this market, this would soon bring a complete change to an AI – guided transportation and would become a reality. All of the three from Uber to Google to General Motors all want ...