Unit V
Unit V
Semantic Analysis
process of understanding the meaning of text at various levels, including word,
sentence, and document levels.
It involves techniques and methods to extract and represent the semantic content of
text data.
Understanding meaning of language for human is easy, but it is difficult to
understand by machine.
So, the goal of semantic analysis is to extract exact meaning, or dictionary meaning,
from the text.
Semantic Analysis of Natural Language can be classified into two parts-
1. Lexical Semantic Analysis
involves understanding the meaning of each word of the text individually.
Itbasically refers to fetching the dictionary meaning that a word in the text is assigned to
carry.
2. Compositional Semantics Analysis
Although knowing the meaning of each word of the text is essential, it is not sufficient to
completely understand the meaning of the text.
understand how combinations of individual words form the meaning of the text.
Lexical Semantics
The semantic analysis process begins by studying and analyzing the dictionary
definitions and meanings of individual words also referred to as lexical
semantics.
analyzing the set of words in the text to understand their meanings.
fetching the dictionary definition for the words in the text.
E.g.the word ‘Blackberry’ could refer to a fruit, a company, or its products,
along with several other meanings.
context is vital in semantic analysis and requires additional information to
assign a correct meaning to the whole sentence or language.
Application of Semantic Analysis
Itis easy to miss sentence fragments because all a series of words needs is a
capital letter at the beginning and ending punctuation. It looks like a sentence.
Yet,for a sentence to be truly complete, it must contain an independent clause,
which tells the whole story even when isolated from its context.
What is a sentence fragment?
A sentence fragment is an incomplete sentence;
it’s a partial sentence that’s missing another necessary part to make it complete.
Put simply, a sentence fragment is a clause that falls short of a complete because
it is missing one of three critical components:
a subject,
a verb, and
a complete thought.
Fixing sentence fragments
Fixing a sentence fragment involves one of two things: giving it the components it
lacks or fastening it onto an independent clause.
E.g. There are many ways to frighten little brothers; for example, you could hide
under their beds and wait for dark.
Notice that in order to properly connect these two clauses with a semicolon, you
need to do some rewriting in order to ensure both can function as independent
clauses. In other words, you need to fortify the fragment with a subject and a
verb to turn it into a sentence. Notice in the example above you’ll need to edit
other parts of your fragment to turn it into a grammatically correct independent
clause.
If a semicolon seems too formal for your purposes, you could write your text as two
sentences—but don’t forget to make sure the second one has a subject and a verb:
E.g. There are many ways to frighten little brothers.
Such as, you could hide under their beds and wait for dark.
Sentence fragment examples
Now the fragment has become a dependent clause attached to a sentence that has a
subject (the party) and a verb (was canceled). Our thought is complete.
E.g. I ran.
I ran may be a short thought, but it has a subject (I) and a verb (ran). Nothing in
the sentence demands further explanation.
Avoiding sentence fragments not only makes your writing easier to read, but it can
also make you sound more polished in polite correspondence. We’ve all had emails
ending with:
E.g. Looking forward to seeing you.
That sentence lacks a subject. Adding the subject will build a stronger, more confident-
sounding sentence:
I’m looking forward to seeing you.
Recast the sentence
Sometimes it’s better to rethink the sentence so that it’s naturally more complete. This could mean
scrapping the entire fragment and starting over from scratch, or it could involve something minor
such as adding a punctuation mark.
Use a grammar tool
Some sentence fragments are easy to identify but not all of them.
Ifyou’re confused about whether you have a sentence fragment or a complete
sentence, try using grammar checker tool, which will identify mistakes and
suggest corrections.
Relations among lexemes & their
senses
Terminology
Word forms:-runs, ran, running. Any, possibly inflected, form of a word.
(Morphology)
Lemma:-A basic word form, used to represent all forms of the same word.
Lexeme:-RUN(V), GOOD(A)
An abstract representation of a word (and all its forms), with a part-of-speech and
a set of related word senses.
Lexicon:-A (finite) list of lexemes.
Relations between words /
senses
Homonymy
Polysemy
Synonymy
Antonymy
Hypernymy
Hyponymy
Meronymy
Homonymy
Homonyms: lexemes that share a form, but unrelated meanings (same spelling and
same pronunciation)
E.g. bat (wooden stick thing) vs bat (flying scary mammal)
bank (financial institution) vs bank (riverside)
It Can be homophones, homographs, or both:
Homophones: write and right, piece and peace(sound the same but are different in
meaning or spelling)
Homographs: bass and bass (sound same/same spelling but diff. meaning)
Homonymy causes problems for NLP applications:-
Senses that are opposites with respect to one feature of their meaning
Two lemmas with the opposite sense
E.g. dark / light, short / long, hot / cold, up / down.
Hyponyms and Hypernyms
Hyponym: - the sense is a subclass of another sense
car is a hyponym of vehicle
dog is a hyponym of animal
mango is a hyponym of fruit
Hypernym: - the sense is a superclass
vehicle is a hypernym of car
animal is a hypernym of dog
fruit is a hypernym of mango
Meronymy
relationship that exists between two
words when one word is a part or a
member of the other.
In this relationship, the part is called
the meronym, and the whole is
called the holonym.
E.g. “wheel” is a meronym of “car,”
and “car” is the holonym of “wheel.”
Semantic Ambiguity
Itis the process of identifying the correct sense of a word from a set of possible
senses, based on the context in which the word appears.
WSD aims to disambiguate the correct sense of a word in a particular context.
E.g. the word “bank” can have different meanings in the sentences –
“I deposited money in the bank”
“The boat went down the river bank”.
Some common approaches to WSD include using WordNet, supervised
machine learning, and unsupervised methods such as clustering.
Difficulties in Word Sense Disambiguation
Part-of-speech tagging and sense tagging have been shown to be very tightly coupled in any
real test, with each potentially constraining the other.
Both disambiguating and tagging with words are involved in WSM part-of-speech tagging.
Sometimes, algorithms designed for one do not always work well for the other, owing to the
fact that a word’s part of speech is mostly decided by the one to three words immediately
adjacent to it, whereas a word’s sense can be determined by words further away.
Sense Inventories for Word Sense Disambiguation
Sense Inventories are the collection of abbreviations and acronyms with their possible
senses. Some of the examples used in Word Sense Disambiguation are:
Princeton WordNet: is a vast lexicographic database of English and other languages that is
manually curated. For WSD, this is the de facto standard inventory. Its well-organized Synsets, or
clusters of contextual synonyms, are nodes in a network.
BabelNet: is a multilingual dictionary that covers both lexicographic and encyclopedic
terminology. It was created by semi-automatically mapping numerous resources, including
WordNet, multilingual versions of WordNet, and Wikipedia.
Wiktionary: a collaborative project aimed at creating a dictionary for each language separately,
is another inventory that has recently gained popularity.
WSD Methods 3. Unsupervised and Semi-
1.Knowledge-Based Methods Supervised Methods
Lesk’s Clustering Approaches
Algorithm
Dictionary Co-occurrence Graphs
and Thesaurus-Based
Methods Semi-Supervised Learning
Graph-Based Algorithms
2. Supervised Learning Methods
Feature-Based Models
Neural Network Models
Sequence Models
1.Knowledge-Based Methods (Lesk‘s
Algorithm)
the correct sense of a word in a given context can be identified by selecting the sense
whose dictionary definition has the greatest overlap with the words in the word's
actual context.
This method utilizes a lexical database such as WordNet, which provides definitions
and example sentences for words in each of their senses.
Necessary Configuration (i/p)
LexicalResource: The algorithm requires a dictionary or a lexical database like
WordNet that provides definitions for each sense of potentially ambiguous words.
Ambiguous Word: Choose the word whose sense needs to be disambiguated based on
the surrounding context.
Steps:-
Word Definition Retrieval: For each sense of the ambiguous word, retrieve the
corresponding dictionary definition.
Contextual Words Extraction: Extract the set of words from the surrounding
context of the ambiguous word in the text.
Overlap Calculation: For each sense, calculate the overlap between the words in
the definition and the words in the context. Overlap is typically the count of
common words, but it can be enhanced to include synonyms, hypernyms, and
other semantic relations.
Sense Selection: The sense with the highest overlap is chosen as the correct sense
for the instance in question.
E.g. Consider the word "bank" in the sentence: "He sat on the river bank.“
Dictionary Definitions (simplified):
Bank (n1): "The land alongside or sloping down to a river or lake."
Bank (n2): "A financial institution that accepts deposits and channels the money into lending activities."
Context: "He sat on the river bank."
Overlap Calculation:
n1: Overlap words might include "river", "land".
n2: No overlap.
The sense "n1" (the land alongside or sloping down to a river or lake) will be selected because it has a
higher overlap with the context words.
Advantages of Lesk Algorithm
A decision list is a sequence of if-then rules arranged in a priority order, where each rule
tests a condition based on the context of the target word.
Working
1. Feature Extraction:
The first step in using a decision list for WSD is to extract features from the training data. These
features typically include:
The words immediately surrounding the ambiguous word.
Part-of-speech tags of the surrounding words.
Collocations or common phrases associated with particular senses of the word.
Possibly syntactic dependencies or semantic patterns.
2. Rule Generation:
Based on the training data, where each instance of the ambiguous word is
labeled with the correct sense, the system generates a list of if-then rules. Each
rule associates a particular pattern or feature with a specific sense of the word.
Rules are typically derived by identifying features that are highly predictive of
a particular sense. For example, the presence of "money" near the word "bank"
might strongly suggest the financial sense of "bank.“
3. Rule Scoring and Ordering:
Each rule is assigned a score based on its predictive power, which might be
calculated using metrics such as pointwise mutual information, likelihood
ratios, or simply frequency counts of the correct classification in the training
data.
The rules are then ordered in a list from the most to the least powerful (i.e., the
rules that are most reliable in predicting a sense come first).
4. Classification:
To disambiguate a new instance of an ambiguous word, the decision list is
processed from top to bottom. The context of the instance is checked against
each rule until a rule that matches the context is found.
The sense associated with the first matching rule is assigned to the word.
E.g. Consider the word "bark." A decision list for "bark" might look like this:
Ifthe word "dog" or "howl" appears near "bark," then "bark" means the sound
a dog makes.
Ifthe word "tree" or "wood" appears near "bark," then "bark" means the outer
covering of a tree.
Default to the sound a dog makes if no other rules apply.
Advantages of Decision Lists for
WSD
Interpretability: Each rule in the list has a clear rationale and is easy to
understand.
Efficiency: Classification involves sequentially checking conditions until a
match is found, which can be very fast.
Flexibility:Rules can be easily added, removed, or modified based on
additional data or insights.
Disadvantages of Decision Lists for
WSD
Overfitting: Highly specific rules might perform well on training data but
poorly on unseen examples.
Data Dependence: The effectiveness of the rules depends heavily on the
quality and representativeness of the training data.
Scalability: As
the number of potential senses and contextual features grows,
managing and prioritizing the rules can become challenging.