from rake_nltk import Rake
def generate_ai_keywords(text): # Initialize Rake object rake = Rake()
# Extract keywords from the text
rake.extract_keywords_from_text(text)
# Get the top 10 keywords with scores
keywords_with_scores = rake.get_ranked_phrases_with_scores()[:10]
# Extract only the keywords without scores
keywords = [keyword for score, keyword in keywords_with_scores]
# Append domain-specific AI keywords
ai_keywords = ['artificial intelligence', 'machine learning', 'deep learning', 'neural networks', 'natural language processing', 'computer vision']
keywords += ai_keywords
return keywords
Example usage
text = "Artificial intelligence is a fascinating field that has gained a lot of attention in recent years. It involves the development of intelligent machines capable of performing tasks that typically require human intelligence." keywords = generate_ai_keywords(text) print(keywords)
Traceback (most recent call last): File "C:\Users\SIRI\PycharmProjects\pythonProject2\main.py", line 1, in from rake_nltk import Rake ModuleNotFoundError: No module named 'rake_nltk'
NOTE : I INSTALLED RAKE MODULE WHILE I'M INSTALLING IT RAISING AN ERROR LIKE
note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed
Encountered error while generating package metadata.
See above for output.
note: This is an issue with the package mentioned above, not pip. hint: See above for details.
[notice] A new release of pip available: 22.3.1 -> 23.1.2 [notice] To update, run: python.exe -m pip install --upgrade pip