### Install engtagger with sudo
Source: https://github.com/yohasebe/engtagger/blob/master/README.md
Installation command requiring root privileges.
```bash
sudo gem install engtagger
```
--------------------------------
### Install engtagger gem
Source: https://github.com/yohasebe/engtagger/blob/master/README.md
Standard installation command for the engtagger gem.
```bash
gem install engtagger
```
--------------------------------
### Adjust file permissions
Source: https://github.com/yohasebe/engtagger/blob/master/README.md
Command to grant ownership of the installed gem directory to the current user after a sudo installation.
```bash
sudo chown -R $(whoami) /Library/Ruby/Gems/2.6.0/gems/engtagger-0.4.2
```
--------------------------------
### Get Readable Tagged Output
Source: https://context7.com/yohasebe/engtagger/llms.txt
Convert text into a word/TAG format for easier review, supporting both abbreviated and verbose tag styles.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "I woke up to the sound of pouring rain."
# Get readable format with abbreviated tags
readable = tagger.get_readable(text)
puts readable
#=> "I/PRP woke/VBD up/RB to/TO the/DET sound/NN of/IN pouring/VBG rain/NN ./PP"
# Get readable format with verbose tags
readable_verbose = tagger.get_readable(text, true)
puts readable_verbose
#=> "I/DETERMINER_POSSESSIVE_SECOND woke/VERB_PAST_TENSE up/ADVERB to/PREPOSITION the/DETERMINER sound/NOUN of/PREPOSITION_OR_CONJUNCTION pouring/VERB_GERUND rain/NOUN ./PUNCTUATION_SENTENCE_ENDER"
```
--------------------------------
### Get Readable Tagged Output (get_readable)
Source: https://context7.com/yohasebe/engtagger/llms.txt
Convert text to a human-readable tagged format with word/TAG notation, making it easy to review tagging results without parsing XML.
```APIDOC
## POST /get_readable
### Description
Convert text to a human-readable tagged format with word/TAG notation, making it easy to review tagging results without parsing XML.
### Method
`get_readable`
### Endpoint
`EngTagger#get_readable(text, verbose = false)`
### Parameters
#### Path Parameters
- **text** (String) - Required - The input text to be tagged.
- **verbose** (Boolean) - Optional - If true, returns verbose tag names; otherwise, returns abbreviated codes. Defaults to false.
### Request Example
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "I woke up to the sound of pouring rain."
# Get readable format with abbreviated tags
readable = tagger.get_readable(text)
puts readable
#=> "I/PRP woke/VBD up/RB to/TO the/DET sound/NN of/IN pouring/VBG rain/NN ./PP"
# Get readable format with verbose tags
readable_verbose = tagger.get_readable(text, true)
puts readable_verbose
#=> "I/DETERMINER_POSSESSIVE_SECOND woke/VERB_PAST_TENSE up/ADVERB to/PREPOSITION the/DETERMINER sound/NOUN of/PREPOSITION_OR_CONJUNCTION pouring/VERB_GERUND rain/NOUN ./PUNCTUATION_SENTENCE_ENDER"
```
### Response
#### Success Response (200)
- **readable_text** (String) - The input text formatted as word/TAG pairs.
#### Response Example
```ruby
# "I/PRP woke/VBD up/RB to/TO the/DET sound/NN of/IN pouring/VBG rain/NN ./PP"
```
```
--------------------------------
### Get Readable Tagged Text
Source: https://github.com/yohasebe/engtagger/blob/master/README.md
Obtain a human-readable version of the tagged text, where each word is followed by its POS tag, separated by a slash.
```ruby
# Get a readable version of the tagged text
readable = tgr.get_readable(text)
#=> "Alice/NNP chased/VBD the/DET big/JJ fat/JJ cat/NN ./PP"
```
--------------------------------
### Get Tag Pairs (tag_pairs)
Source: https://context7.com/yohasebe/engtagger/llms.txt
Return an array of word-tag pairs for programmatic processing. Each element is a two-element array containing the word and its tag as a symbol.
```APIDOC
## POST /tag_pairs
### Description
Return an array of word-tag pairs for programmatic processing. Each element is a two-element array containing the word and its tag as a symbol.
### Method
`tag_pairs`
### Endpoint
`EngTagger#tag_pairs(text)`
### Parameters
#### Path Parameters
- **text** (String) - Required - The input text to be tagged.
### Request Example
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "The quick brown fox jumps."
pairs = tagger.tag_pairs(text)
pairs.each do |word, tag|
puts "#{word} => #{tag}"
end
#=> The => :det
#=> quick => :jj
#=> brown => :jj
#=> fox => :nn
#=> jumps => :vbz
#=> . => :pp
# Filter for specific parts of speech
nouns = pairs.select { |word, tag| tag == :nn }
puts nouns.map(&:first)
#=> ["fox"]
```
### Response
#### Success Response (200)
- **tag_pairs** (Array of Arrays) - An array where each inner array contains a word (String) and its corresponding tag (Symbol).
#### Response Example
```ruby
# [["The", :det], ["quick", :jj], ["brown", :jj], ["fox", :nn], ["jumps", :vbz], [".", :pp]]
```
```
--------------------------------
### Initialize EngTagger Instance
Source: https://context7.com/yohasebe/engtagger/llms.txt
Create a tagger instance with default or custom configuration options for stemming, noun phrase limits, and HMM relaxation.
```ruby
require 'engtagger'
# Basic initialization with defaults
tagger = EngTagger.new
# Initialize with custom configuration options
tagger = EngTagger.new(
stem: true, # Enable Porter stemming for single words
longest_noun_phrase: 3, # Limit noun phrases to 3 words max
weight_noun_phrases: true, # Weight counts by word count in noun phrases
relax: true, # Relax HMM for better accuracy on uncommon words
unknown_word_tag: "nn" # Tag unknown words as nouns
)
# Access or modify configuration after initialization
tagger.conf[:stem] = false
puts tagger.conf[:longest_noun_phrase]
#=> 3
```
--------------------------------
### Initialize EngTagger and Tag Text
Source: https://github.com/yohasebe/engtagger/blob/master/README.md
Create a new EngTagger object and add part-of-speech tags to a given text. The output includes tags enclosed in angle brackets.
```ruby
require 'engtagger'
# Create a parser object
tgr = EngTagger.new
# Sample text
text = "Alice chased the big fat cat."
# Add part-of-speech tags to text
tagged = tgr.add_tags(text)
#=> "Alice chased the big fatcat ."
```
--------------------------------
### EngTagger Initialization
Source: https://context7.com/yohasebe/engtagger/llms.txt
Initialize the EngTagger with optional configuration parameters to customize behavior such as stemming, noun phrase handling, and unknown word classification.
```APIDOC
## EngTagger Initialization
### Description
Initialize the tagger with optional configuration parameters to customize behavior such as stemming, noun phrase handling, and unknown word classification.
### Method
`EngTagger.new`
### Parameters
#### Query Parameters
- **stem** (Boolean) - Optional - Enable Porter stemming for single words.
- **longest_noun_phrase** (Integer) - Optional - Limit noun phrases to a maximum number of words.
- **weight_noun_phrases** (Boolean) - Optional - Weight counts by word count in noun phrases.
- **relax** (Boolean) - Optional - Relax HMM for better accuracy on uncommon words.
- **unknown_word_tag** (String) - Optional - Tag unknown words with a specified tag (e.g., "nn").
### Request Example
```ruby
require 'engtagger'
# Basic initialization with defaults
tagger = EngTagger.new
# Initialize with custom configuration options
tagger = EngTagger.new(
stem: true,
longest_noun_phrase: 3,
weight_noun_phrases: true,
relax: true,
unknown_word_tag: "nn"
)
# Access or modify configuration after initialization
tagger.conf[:stem] = false
puts tagger.conf[:longest_noun_phrase]
#=> 3
```
### Response
#### Success Response (200)
- **tagger instance** - An initialized EngTagger object.
#### Response Example
```ruby
# tagger object is returned
```
```
--------------------------------
### Explain POS Tags
Source: https://context7.com/yohasebe/engtagger/llms.txt
Converts abbreviated POS tags into human-readable strings using the class method explain_tag.
```ruby
require 'engtagger'
# Explain individual tags
puts EngTagger.explain_tag("nn") #=> "noun"
puts EngTagger.explain_tag("vb") #=> "verb_infinitive"
puts EngTagger.explain_tag("vbd") #=> "verb_past_tense"
puts EngTagger.explain_tag("jj") #=> "adjective"
puts EngTagger.explain_tag("jjr") #=> "adjective_comparative"
puts EngTagger.explain_tag("rb") #=> "adverb"
puts EngTagger.explain_tag("nnp") #=> "noun_proper"
puts EngTagger.explain_tag("det") #=> "determiner"
puts EngTagger.explain_tag("pp") #=> "punctuation_sentence_ender"
puts EngTagger.explain_tag("cc") #=> "conjunction_coordinating"
```
--------------------------------
### Explaining Tags (explain_tag)
Source: https://context7.com/yohasebe/engtagger/llms.txt
Converts abbreviated Part-of-Speech (POS) tags into human-readable descriptions. This is a class method.
```APIDOC
## Explaining Tags (explain_tag)
### Description
Convert abbreviated POS tags to human-readable descriptions.
### Method
`EngTagger.explain_tag(tag)`
### Parameters
* `tag` (String) - The abbreviated POS tag to explain.
### Request Example
```ruby
require 'engtagger'
# Explain individual tags
puts EngTagger.explain_tag("nn") #=> "noun"
puts EngTagger.explain_tag("vb") #=> "verb_infinitive"
puts EngTagger.explain_tag("vbd") #=> "verb_past_tense"
puts EngTagger.explain_tag("jj") #=> "adjective"
puts EngTagger.explain_tag("jjr") #=> "adjective_comparative"
puts EngTagger.explain_tag("rb") #=> "adverb"
puts EngTagger.explain_tag("nnp") #=> "noun_proper"
puts EngTagger.explain_tag("det") #=> "determiner"
puts EngTagger.explain_tag("pp") #=> "punctuation_sentence_ender"
puts EngTagger.explain_tag("cc") #=> "conjunction_coordinating"
```
### Response
* Returns a String describing the POS tag.
```
--------------------------------
### Splitting Text into Sentences (get_sentences)
Source: https://context7.com/yohasebe/engtagger/llms.txt
Splits input text into individual sentences, intelligently handling abbreviations and other edge cases.
```APIDOC
## Splitting Text into Sentences (get_sentences)
### Description
Split text into individual sentences, handling abbreviations and edge cases intelligently.
### Method
`get_sentences(text)`
### Parameters
* `text` (String) - The input text to be split into sentences.
### Request Example
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "Dr. Watson arrived at 5 p.m. He met Mr. Holmes. They discussed the case. It was elementary!"
sentences = tagger.get_sentences(text)
sentences.each_with_index do |sentence, i|
puts "#{i + 1}: #{sentence}"
end
#=> 1: Dr. Watson arrived at 5 p.m.
#=> 2: He met Mr. Holmes.
#=> 3: They discussed the case.
#=> 4: It was elementary!
# Handles U.S. style abbreviations
text = "He is a U.S. Army officer. He served in Washington D.C."
sentences = tagger.get_sentences(text)
puts sentences.length
#=> 2
```
### Response
* Returns an Array of Strings, where each string is a sentence from the input text.
```
--------------------------------
### Add XML-style POS Tags to Text
Source: https://context7.com/yohasebe/engtagger/llms.txt
Generate text with XML-style tags indicating grammatical roles, with an option for verbose human-readable tag names.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "Alice chased the big fat cat."
# Get XML-style tagged output
tagged = tagger.add_tags(text)
puts tagged
#=> "Alice chased the big fat cat ."
# Get verbose tagged output with full tag names
verbose_tagged = tagger.add_tags(text, true)
puts verbose_tagged
#=> "Alice chased the big fat cat ."
```
--------------------------------
### Split Text into Sentences
Source: https://context7.com/yohasebe/engtagger/llms.txt
Segments raw text into individual sentences while handling common abbreviations like U.S. or titles.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "Dr. Watson arrived at 5 p.m. He met Mr. Holmes. They discussed the case. It was elementary!"
sentences = tagger.get_sentences(text)
sentences.each_with_index do |sentence, i|
puts "#{i + 1}: #{sentence}"
end
#=> 1: Dr. Watson arrived at 5 p.m.
#=> 2: He met Mr. Holmes.
#=> 3: They discussed the case.
#=> 4: It was elementary!
# Handles U.S. style abbreviations
text = "He is a U.S. Army officer. He served in Washington D.C."
sentences = tagger.get_sentences(text)
puts sentences.length
#=> 2
```
--------------------------------
### Apply Porter Stemming
Source: https://context7.com/yohasebe/engtagger/llms.txt
Reduces words to their root forms using the Porter stemming algorithm, either directly on strings or globally within the tagger.
```ruby
require 'engtagger'
# Direct string stemming (available on all String objects)
puts "running".stem #=> "run"
puts "cats".stem #=> "cat"
puts "generalization".stem #=> "gener"
puts "happiness".stem #=> "happi"
# Enable stemming in tagger
tagger = EngTagger.new(stem: true)
text = "The running cats were chasing flying birds."
tagged = tagger.add_tags(text)
# Stemmed noun extraction
nouns = tagger.get_nouns(tagged)
puts nouns
#=> {"cat"=>1, "bird"=>1} # Plurals stemmed
# Toggle stemming at runtime
tagger.conf[:stem] = false
nouns = tagger.get_nouns(tagged)
puts nouns
#=> {"cats"=>1, "birds"=>1} # Original forms preserved
```
--------------------------------
### get_adverbs
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts all adverbs from tagged text.
```APIDOC
## get_adverbs
### Description
Extracts all adverbs from tagged text, including regular adverbs, comparative, superlative, and particle adverbs.
### Parameters
#### Request Body
- **tagged** (string) - Required - The POS-tagged text string generated by add_tags.
### Response
- **Hash** - A hash where keys are the adverbs and values are their occurrence counts.
```
--------------------------------
### get_conjunctions
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts coordinating and subordinating conjunctions and prepositions.
```APIDOC
## get_conjunctions
### Description
Extracts coordinating and subordinating conjunctions and prepositions from tagged text.
### Parameters
#### Request Body
- **tagged** (string) - Required - The POS-tagged text string generated by add_tags.
### Response
- **Hash** - A hash where keys are the conjunctions/prepositions and values are their occurrence counts.
```
--------------------------------
### Using Porter Stemmer
Source: https://context7.com/yohasebe/engtagger/llms.txt
EngTagger includes the Porter stemming algorithm for reducing words to their root forms. Stemming can be enabled globally or used directly on strings.
```APIDOC
## Using Porter Stemmer
### Description
Applies the Porter stemming algorithm to reduce words to their root forms. Stemming can be enabled globally or used directly on strings.
### Methods
* **Direct Stemming**: `String#stem`
* **Tagger Configuration**: `EngTagger.new(stem: true)` or `tagger.conf[:stem] = true/false`
### Parameters
* **`stem: true/false`** (Boolean) - Option to enable/disable stemming when initializing EngTagger.
* **`tagger.conf[:stem]`** (Boolean) - Runtime toggle for stemming.
### Request Example
```ruby
require 'engtagger'
# Direct string stemming (available on all String objects)
puts "running".stem #=> "run"
puts "cats".stem #=> "cat"
puts "generalization".stem #=> "gener"
puts "happiness".stem #=> "happi"
# Enable stemming in tagger
tagger = EngTagger.new(stem: true)
text = "The running cats were chasing flying birds."
tagged = tagger.add_tags(text)
# Stemmed noun extraction
nouns = tagger.get_nouns(tagged)
puts nouns
#=> {"cat"=>1, "bird"=>1} # Plurals stemmed
# Toggle stemming at runtime
tagger.conf[:stem] = false
nouns = tagger.get_nouns(tagged)
puts nouns
#=> {"cats"=>1, "birds"=>1} # Original forms preserved
```
### Response
* Direct stemming returns the stemmed version of the string.
* When stemming is enabled in the tagger, extraction methods like `get_nouns` will return stemmed results.
```
--------------------------------
### Retrieve Tag Pairs
Source: https://context7.com/yohasebe/engtagger/llms.txt
Obtain an array of word-tag pairs for programmatic processing, allowing for easy filtering by part of speech.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "The quick brown fox jumps."
pairs = tagger.tag_pairs(text)
pairs.each do |word, tag|
puts "#{word} => #{tag}"
end
#=> The => :det
#=> quick => :jj
#=> brown => :jj
#=> fox => :nn
#=> jumps => :vbz
#=> . => :pp
# Filter for specific parts of speech
nouns = pairs.select { |word, tag| tag == :nn }
puts nouns.map(&:first)
#=> ["fox"]
```
--------------------------------
### Add POS Tags to Text (add_tags)
Source: https://context7.com/yohasebe/engtagger/llms.txt
Tag text with XML-style part-of-speech tags. The verbose option provides human-readable tag names instead of abbreviated codes.
```APIDOC
## POST /add_tags
### Description
Tag text with XML-style part-of-speech tags. Each word is wrapped in tags indicating its grammatical role. The verbose option provides human-readable tag names instead of abbreviated codes.
### Method
`add_tags`
### Endpoint
`EngTagger#add_tags(text, verbose = false)`
### Parameters
#### Path Parameters
- **text** (String) - Required - The input text to be tagged.
- **verbose** (Boolean) - Optional - If true, returns verbose tag names; otherwise, returns abbreviated codes. Defaults to false.
### Request Example
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "Alice chased the big fat cat."
# Get XML-style tagged output
tagged = tagger.add_tags(text)
puts tagged
#=> "Alice chased the big fat cat ."
# Get verbose tagged output with full tag names
verbose_tagged = tagger.add_tags(text, true)
puts verbose_tagged
#=> "Alice chased the big fat cat ."
```
### Response
#### Success Response (200)
- **tagged_text** (String) - The input text with part-of-speech tags applied.
#### Response Example
```ruby
# "Alice chased the big fat cat ."
```
```
--------------------------------
### get_verbs
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts all verbs of any type from tagged text.
```APIDOC
## get_verbs
### Description
Extracts all verbs of any type from tagged text. This combines all verb forms including infinitive, past tense, gerund, passive, and present tense.
### Parameters
#### Request Body
- **tagged** (string) - Required - The POS-tagged text string generated by add_tags.
### Response
- **Hash** - A hash where keys are the verbs and values are their occurrence counts.
```
--------------------------------
### Extract Adverbs with EngTagger
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts all adverbs from tagged text, including regular, comparative, superlative, and particle adverbs. Requires pre-tagged input.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "She quickly ran up the stairs and arrived faster than expected."
tagged = tagger.add_tags(text)
adverbs = tagger.get_adverbs(tagged)
puts adverbs
#=> {"quickly"=>1, "up"=>1, "faster"=>1}
```
--------------------------------
### POS Tag Reference
Source: https://context7.com/yohasebe/engtagger/llms.txt
Provides a reference for the modified Penn Treebank POS tags used by EngTagger.
```APIDOC
## POS Tag Reference
### Description
Reference for the modified Penn Treebank tag set used by EngTagger.
### Tag Set
* **CC**: Conjunction, coordinating (and, or)
* **CD**: Adjective, cardinal number (3, fifteen)
* **DET**: Determiner (this, each, some)
* **JJ**: Adjective (happy, bad)
* **JJR**: Adjective, comparative (happier, worse)
* **JJS**: Adjective, superlative (happiest, worst)
* **NN**: Noun (aircraft, data)
* **NNP**: Noun, proper (London, Michael)
* **NNS**: Noun, plural (women, books)
* **RB**: Adverb (often, not, very)
* **VB**: Verb, infinitive (take, live)
* **VBD**: Verb, past tense (took, lived)
* **VBG**: Verb, gerund (taking, living)
* **VBN**: Verb, past/passive participle (taken, lived)
* **VBZ**: Verb, present 3SG (takes, lives)
* **PP**: Punctuation, sentence ender (., !, ?)
### Example Usage
```ruby
require 'engtagger'
# Example: Filter tagged output by specific tags
tagger = EngTagger.new
text = "The quick brown fox jumps over the lazy dog."
tagged = tagger.add_tags(text)
# Extract words matching specific tag patterns
adjectives = tagged.scan(/([^<]+)<\/jj>/).flatten
puts adjectives
#=> ["quick", "brown", "lazy"]
```
### Response
* This section serves as a reference and does not have a direct request/response structure.
```
--------------------------------
### Extract Words and Noun Phrases
Source: https://github.com/yohasebe/engtagger/blob/master/README.md
Retrieve a list of all nouns and noun phrases from the text along with their occurrence counts. This method can take raw text as input.
```ruby
# Get a list of all nouns and noun phrases with occurrence counts
word_list = tgr.get_words(text)
#=> {"Alice"=>1, "cat"=>1, "fat cat"=>1, "big fat cat"=>1}
```
--------------------------------
### Extract Proper Nouns with EngTagger
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts proper nouns, automatically combining multi-word phrases and resolving acronyms to their full names. Requires pre-tagged input.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "Lisa Raines works for the Industrial Biotechnical Association in New York."
tagged = tagger.add_tags(text)
proper_nouns = tagger.get_proper_nouns(tagged)
puts proper_nouns
#=> {"Lisa Raines"=>1, "Industrial Biotechnical Association"=>1, "New York"=>1}
```
```ruby
# Acronym resolution example
text = "BBC means British Broadcasting Corporation. The BBC is headquartered in London."
tagged = tagger.add_tags(text)
proper_nouns = tagger.get_proper_nouns(tagged)
puts proper_nouns
#=> {"British Broadcasting Corporation"=>2, "London"=>1} # BBC merged with full name
```
--------------------------------
### get_noun_phrases
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts all noun phrases from tagged text at various syntactic levels.
```APIDOC
## get_noun_phrases
### Description
Extracts all noun phrases from tagged text at various syntactic levels, including nested phrases. Returns phrases with occurrence counts.
### Parameters
#### Request Body
- **tagged** (string) - Required - The POS-tagged text string generated by add_tags.
### Response
- **Hash** - A hash where keys are the noun phrases and values are their occurrence counts.
```
--------------------------------
### get_nouns
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts all nouns from POS-tagged text with their occurrence frequencies.
```APIDOC
## get_nouns
### Description
Extracts all nouns from POS-tagged text with their occurrence frequencies. Requires pre-tagged input from add_tags.
### Parameters
#### Request Body
- **tagged** (string) - Required - The POS-tagged text string generated by add_tags.
### Response
- **Hash** - A hash where keys are the nouns and values are their occurrence counts.
```
--------------------------------
### Extract Words and Noun Phrases (get_words)
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extract all nouns and noun phrases from untagged text with occurrence counts. This method automatically tags the text and recursively extracts noun phrases at all syntactic levels.
```APIDOC
## POST /get_words
### Description
Extract all nouns and noun phrases from untagged text with occurrence counts. This method automatically tags the text and recursively extracts noun phrases at all syntactic levels.
### Method
`get_words`
### Endpoint
`EngTagger#get_words(text)`
### Parameters
#### Path Parameters
- **text** (String) - Required - The input text from which to extract words and noun phrases.
### Request Example
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "Alice chased the big fat cat."
# Get all words and noun phrases with counts
word_list = tagger.get_words(text)
puts word_list
#=> {"Alice"=>1, "cat"=>1, "fat cat"=>1, "big fat cat"=>1}
# Limit noun phrase length
tagger.conf[:longest_noun_phrase] = 2
word_list = tagger.get_words(text)
puts word_list
#=> {"Alice"=>1, "cat"=>1, "fat cat"=>1}
# With stemming enabled
tagger.conf[:stem] = true
tagger.conf[:longest_noun_phrase] = 1
word_list = tagger.get_words("The cats were chasing mice.")
puts word_list
#=> {"cat"=>1, "mice"=>1} # "cats" stemmed to "cat"
```
### Response
#### Success Response (200)
- **word_list** (Hash) - A hash where keys are extracted words/noun phrases and values are their occurrence counts.
#### Response Example
```ruby
# {"Alice"=>1, "cat"=>1, "fat cat"=>1, "big fat cat"=>1}
```
```
--------------------------------
### get_proper_nouns
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts proper nouns from tagged text, combining multi-word phrases and resolving acronyms.
```APIDOC
## get_proper_nouns
### Description
Extracts proper nouns from tagged text, automatically combining multi-word proper noun phrases and resolving acronyms to their full names.
### Parameters
#### Request Body
- **tagged** (string) - Required - The POS-tagged text string generated by add_tags.
### Response
- **Hash** - A hash where keys are the proper nouns and values are their occurrence counts.
```
--------------------------------
### Extract All Noun Phrases from Tagged Text
Source: https://github.com/yohasebe/engtagger/blob/master/README.md
Retrieve all noun phrases of any syntactic level from text that has already been tagged. This method is similar to `get_words` but requires tagged input.
```ruby
# Get all noun phrases of any syntactic level
# (same as word_list but take a tagged input)
nps = tgr.get_noun_phrases(tagged)
#=> {"Alice"=>1, "cat"=>1, "fat cat"=>1, "big fat cat"=>1}
```
--------------------------------
### Extract Verbs with EngTagger
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts all verb forms (infinitive, past tense, gerund, passive, present) from tagged text. Specific methods are available for each verb type.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "Lisa contends that a judge would have ruled otherwise."
tagged = tagger.add_tags(text)
verbs = tagger.get_verbs(tagged)
puts verbs
#=> {"contends"=>1, "have"=>1, "ruled"=>1}
```
```ruby
# Get specific verb types
infinitive_verbs = tagger.get_infinitive_verbs(tagged)
puts infinitive_verbs
#=> {"have"=>1}
```
```ruby
past_tense_verbs = tagger.get_past_tense_verbs(tagged)
puts past_tense_verbs
#=> {}
```
```ruby
gerund_verbs = tagger.get_gerund_verbs(tagged)
puts gerund_verbs
#=> {}
```
```ruby
passive_verbs = tagger.get_passive_verbs(tagged)
puts passive_verbs
#=> {"ruled"=>1}
```
```ruby
present_verbs = tagger.get_present_verbs(tagged)
puts present_verbs
#=> {"contends"=>1}
```
--------------------------------
### Extract Conjunctions with EngTagger
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts coordinating and subordinating conjunctions, as well as prepositions, from tagged text. Requires pre-tagged input.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "The lawyer and director of government relations for the association contends that a judge would have ruled otherwise."
tagged = tagger.add_tags(text)
conjunctions = tagger.get_conjunctions(tagged)
puts conjunctions
#=> {"and"=>1, "of"=>1, "for"=>1, "that"=>1}
```
--------------------------------
### Extracting Interrogatives (get_interrogatives)
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts question words (interrogative pronouns, determiners, and adverbs) from tagged text. An alias `get_question_parts` is also available.
```APIDOC
## Extracting Interrogatives (get_interrogatives)
### Description
Extract question words (interrogative pronouns, determiners, and adverbs) from tagged text.
### Method
`get_interrogatives(tagged_text)`
`get_question_parts(tagged_text)`
### Parameters
* `tagged_text` (Hash) - The text that has been processed by `add_tags`.
### Request Example
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "Who knows which way to go and when to stop?"
tagged = tagger.add_tags(text)
interrogatives = tagger.get_interrogatives(tagged)
puts interrogatives
#=> {"Who"=>1, "which"=>1, "when"=>1}
# Alias method
question_parts = tagger.get_question_parts(tagged)
puts question_parts
#=> {"Who"=>1, "which"=>1, "when"=>1}
```
### Response
* Returns a Hash where keys are the interrogative words and values are their counts.
```
--------------------------------
### Extract Nouns with EngTagger
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts all nouns from POS-tagged text and counts their occurrences. Supports stemming to group plural forms with singular nouns.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "The lawyer and director discussed patent law and government relations."
tagged = tagger.add_tags(text)
nouns = tagger.get_nouns(tagged)
puts nouns
#=> {"lawyer"=>1, "director"=>1, "patent"=>1, "law"=>1, "government"=>1, "relations"=>1}
```
```ruby
# With stemming enabled
tagger.conf[:stem] = true
tagged = tagger.add_tags("The lawyers discussed laws.")
nouns = tagger.get_nouns(tagged)
puts nouns
#=> {"lawyer"=>1, "law"=>1} # Plurals stemmed to singular
```
--------------------------------
### Extract Interrogatives with EngTagger
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts question words from tagged text using the get_interrogatives method or its alias get_question_parts.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "Who knows which way to go and when to stop?"
tagged = tagger.add_tags(text)
interrogatives = tagger.get_interrogatives(tagged)
puts interrogatives
#=> {"Who"=>1, "which"=>1, "when"=>1}
# Alias method
question_parts = tagger.get_question_parts(tagged)
puts question_parts
#=> {"Who"=>1, "which"=>1, "when"=>1}
```
--------------------------------
### Extract Noun Phrases with EngTagger
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts noun phrases at various syntactic levels, including nested phrases, and returns their occurrence counts. Can also retrieve only maximal (longest) phrases.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "The experienced patent lawyer reviewed the complex legal documents."
tagged = tagger.add_tags(text)
noun_phrases = tagger.get_noun_phrases(tagged)
puts noun_phrases
#=> {"lawyer"=>1, "patent lawyer"=>1, "experienced patent lawyer"=>1, "documents"=>1, "legal documents"=>1, "complex legal documents"=>1}
```
```ruby
# Get only maximal noun phrases (longest phrases)
max_phrases = tagger.get_max_noun_phrases(tagged)
puts max_phrases
#=> {"experienced patent lawyer"=>1, "complex legal documents"=>1}
```
--------------------------------
### Extract Adjectives with EngTagger
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts adjectives from tagged text, including base, comparative, and superlative forms. Separate methods exist for each form.
```ruby
require 'engtagger'
tagger = EngTagger.new
text = "The big fat cat is happier than the small thin mouse, but the elephant is the happiest."
tagged = tagger.add_tags(text)
# Get all adjectives (base form only)
adjectives = tagger.get_adjectives(tagged)
puts adjectives
#=> {"big"=>1, "fat"=>1, "small"=>1, "thin"=>1}
```
```ruby
# Get comparative adjectives
comparative = tagger.get_comparative_adjectives(tagged)
puts comparative
#=> {"happier"=>1}
```
```ruby
# Get superlative adjectives
superlative = tagger.get_superlative_adjectives(tagged)
puts superlative
#=> {"happiest"=>1}
```
--------------------------------
### Filter POS Tagged Output
Source: https://context7.com/yohasebe/engtagger/llms.txt
Uses regular expressions to extract specific parts of speech from the tagged output string.
```ruby
require 'engtagger'
# Common tag mappings for reference:
# CC - Conjunction, coordinating (and, or)
# CD - Adjective, cardinal number (3, fifteen)
# DET - Determiner (this, each, some)
# JJ - Adjective (happy, bad)
# JJR - Adjective, comparative (happier, worse)
# JJS - Adjective, superlative (happiest, worst)
# NN - Noun (aircraft, data)
# NNP - Noun, proper (London, Michael)
# NNS - Noun, plural (women, books)
# RB - Adverb (often, not, very)
# VB - Verb, infinitive (take, live)
# VBD - Verb, past tense (took, lived)
# VBG - Verb, gerund (taking, living)
# VBN - Verb, past/passive participle (taken, lived)
# VBZ - Verb, present 3SG (takes, lives)
# PP - Punctuation, sentence ender (., !, ?)
# Example: Filter tagged output by specific tags
tagger = EngTagger.new
text = "The quick brown fox jumps over the lazy dog."
tagged = tagger.add_tags(text)
# Extract words matching specific tag patterns
adjectives = tagged.scan(/([^<]+)<\/jj>/).flatten
puts adjectives
#=> ["quick", "brown", "lazy"]
```
--------------------------------
### get_adjectives
Source: https://context7.com/yohasebe/engtagger/llms.txt
Extracts adjectives from tagged text, including base, comparative, and superlative forms.
```APIDOC
## get_adjectives
### Description
Extracts adjectives from tagged text, including base, comparative, and superlative forms.
### Parameters
#### Request Body
- **tagged** (string) - Required - The POS-tagged text string generated by add_tags.
### Response
- **Hash** - A hash where keys are the adjectives and values are their occurrence counts.
```
--------------------------------
### Extract Specific Word Types from Tagged Output
Source: https://github.com/yohasebe/engtagger/blob/master/README.md
Extract specific types of words (nouns, proper nouns, past tense verbs, adjectives) from text that has already been tagged using `add_tags`.
```ruby
# Get all nouns from a tagged output
nouns = tgr.get_nouns(tagged)
#=> {"cat"=>1, "Alice"=>1}
```
```ruby
# Get all proper nouns
proper = tgr.get_proper_nouns(tagged)
#=> {"Alice"=>1}
```
```ruby
# Get all past tense verbs
pt_verbs = tgr.get_past_tense_verbs(tagged)
#=> {"chased"=>1}
```
```ruby
# Get all the adjectives
adj = tgr.get_adjectives(tagged)
#=> {"big"=>1, "fat"=>1}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.