Need to swap verb phrases?
To eliminate the passive voice from particular phrases. This normalization is helpful with frequency analysis, by counting two apparently different phrases as the same phrase.
The code below is
swap_verb_phrase class that swaps the left-hand side of the chunk with the right-hand side, using the verb as the pivot point. It uses
first_chunk_index() function defined in order to find the verb to pivot around.
Code #1 : swap_verb_phrase class to swap verb
Code #2 : Evaluating swap_verb_phrase
[('great', 'JJ'), ('the', 'DT'), ('book', 'NN')]
The code is not pivoting around a gerund because they are commonly used to describe nouns.
Code #3 :
[('fantastic', 'JJ'), ('this', 'DT'), ('gripping', 'VBG'), ('book', 'NN')]
Swapping noun cardinals :
Cardinals in a chunk refer to a number and are tagged as CD. These cardinals occur before acardinals noun. Swapping noun cardianals is useful to put the cardinal before the noun.
Code #4 : Swapping noun cardinals
[('10', 'CD'), ('Dec.', 'NNP')] [('the', 'DT'), ('10', 'CD'), ('top', 'NN')]
- NLP | Proper Noun Extraction
- NLP | Singularizing Plural Nouns and Swapping Infinite Phrases
- NLP | Verb Forms Correction
- NLP | Chunking and chinking with RegEx
- NLP | Training a tokenizer and filtering stopwords in a sentence
- NLP | Splitting and Merging Chunks
- NLP | Expanding and Removing Chunks with RegEx
- NLP | Leacock Chordorow (LCH) and Path similarity for Synset
- NLP | Regex and Affix tagging
- NLP | Chunk Tree to Text and Chaining Chunk Transformation
- NLP | How to score words with Execnet and Redis
- NLP | Classifier-based Chunking | Set 2
- Processing text using NLP | Basics
- Readability Index in Python(NLP)
- Feature Extraction Techniques - NLP
- Python | NLP analysis of Restaurant reviews
- Applying Multinomial Naive Bayes to NLP Problems
- NLP | Training Unigram Tagger
- NLP | Synsets for a word in WordNet
- NLP | Part of Speech - Default Tagging
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.