Unveiling Linguistics with SpaCy

Mansoor Aldosari
1 min readOct 29, 2023

--

Photo by Bilal O. on Unsplash

In the world of language analysis, SpaCy allows us to dissect the linguistic features. Let’s explore some texts using SpaCy’s capabilities.

!pip install spacy
!python -m spacy download en_core_web_sm

import spacy

# Load the English language model in SpaCy
nlp = spacy.load('en_core_web_sm')

# Texts
text_1 = "Salim, a proficient programmer, designs innovative algorithms and develops software solutions, streamlining complex processes for tech companies."
text_2 = "Saska, a cybersecurity expert, meticulously fortifies networks, ensuring data integrity and safeguarding against cyber threats for large corporations."

# Process Text 1 and Text 2
doc_1 = nlp(text_1)
doc_2 = nlp(text_2)

# Function to display semantic analysis results
def display_analysis(doc):
print("Tokenization & Part-of-Speech Tagging:")
for token in doc:
print(f"Token: {token.text}, POS: {token.pos_}")

print("\nNamed Entity Recognition (NER):")
for ent in doc.ents:
print(f"Entity: {ent.text}, Label: {ent.label_}")

# Analyzing Text 1
print("Analysis of Text 1:")
display_analysis(doc_1)
print("\n----------------\n")

# Analyzing Text 2
print("Analysis of Text 2:")
display_analysis(doc_2)

This concise piece provides a snippet of code, analysis insights, and a brief conclusion on how SpaCy helps uncover the distinct linguistic traits of texts.

--

--

No responses yet