For a list of language codes and corresponding languages, see Language codes.
Capabilities
The keywords and text rank block ranks noun phrases extracted from an input document based on how relevant they are within the document.
Capabilities of keyword extraction and ranking based on an example
Capabilities
Examples
Ranks extracted noun phrases based on relevance
"Anna went to school at University of California Santa Cruz. Anna joined the university in 2015." -> Anna, University of California Santa Cruz
Keyword extraction
Copy link to section
Block name
keywords_embed-rank_multi_stock
Dependencies on other blocks
The following blocks must run before you can run the Keyword extraction with ranking block:
syntax_izumo_<language>_stock
noun-phrases_rbr_<language>_stock
Code sample
import watson_nlp
from watson_nlp import data_model as dm
text = "Anna went to school at University of California Santa Cruz. \
Anna joined the university in 2015."# Load Noun Phrases, Embedding and Keywords models for English
noun_phrases_model = watson_nlp.load('noun-phrases_rbr_en_stock')
use_model = watson_nlp.load('embedding_use_en_stock')
keywords_model = watson_nlp.load('keywords_embed-rank_multi_stock')
# Run the Noun Phrases model
noun_phrases = noun_phrases_model.run(text)
# Get document embeddings# No need to run any Syntax model since the 'raw_text' embed style will be used for doc embedding
syntax_analysis = dm.SyntaxPrediction(text=text)
doc_embeddings = use_model.run(syntax_analysis, doc_embed_style='raw_text')
# Get embeddings for noun phrases
noun_phrases_analysis = [dm.SyntaxPrediction(text=c.span.text) for c in noun_phrases.noun_phrases]
noun_phrase_embeddings = use_model.run_batch(noun_phrases_analysis, doc_embed_style='raw_text')
# Run the keywords model
keywords = keywords_model.run(doc_embeddings, noun_phrases, noun_phrase_embeddings, limit=2, beta=0.5)
print(keywords)
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review your cookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.