Acrony-Finder-Spacy

Sat 17 May 2025

# !pip install spacy
import spacy
spacy.__version__
'3.8.2'
# !python -m spacy download en_core_web_sm
import re
# Load the spaCy model
nlp = spacy.load("en_core_web_sm")
# Sample text
text = "California Xgb is a great tool for machine learning. Another example is AI. \
NTLK is very slow and not recommended high speed ML scenarios. XGBoost, Claude, PrettyMetrics, Rl, Gan, Rnn"
# Tokenize and process the text
doc = nlp(text)
# Define a function to extract acronyms
def find_acronyms(text):
    # Match patterns for acronyms: Uppercase words or mixed case like "Xgb"
    pattern = re.compile(r'\b[A-Z]{2,5}\b|\b[A-Z][a-zA-Z0-9]{2,4}\b')
    return pattern.findall(text)
# Extract acronyms
acronyms = find_acronyms(text)
print("Acronyms found:", acronyms)
Acronyms found: ['Xgb', 'AI', 'NTLK', 'ML', 'Gan', 'Rnn']


Score: 10

Category: spacy

Page 1 of 1