תויעבט תופש דוביע natural language processing רצנ לעי תיתוכאלמ הניב

Download Report

Transcript תויעבט תופש דוביע natural language processing רצנ לעי תיתוכאלמ הניב

‫עיבוד שפות טבעיות‬
‫‪natural language processing‬‬
‫יעל נצר‬
‫בינה מלאכותית‬
‫מכללת אשקלון‬
‫סוגים של התקשרות בעזרת שפה‬
‫• שאלות ‪query‬‬
‫– "האם ראית את הסוס הנהדר הזה?"‬
‫• יידוע ‪inform‬‬
‫– "מחירו של הניגון הוא חמישים רובל"‬
‫• בקשה ‪request‬‬
‫– "נא למדני את השיר"‬
‫• אישור ‪acknowledge‬‬
‫– "בסדר" ‪!ok‬‬
‫• הבטחה ‪promise‬‬
‫– "חמישים שילמתי ואוסיף את מגפי!"‬
‫מטרות התקשורת‬
‫• שינוי מצב מנטאלי ופעולות עתידיות‬
‫• העברת מידע – השפעה על קבלת החלטות‬
‫• הצהרה (דקלרטיביות) ‪I now pronounce you " -‬‬
‫!‪"man and wife‬‬
‫אבני היסוד של השפה‬
‫• שפה פורמלית‪ :‬מוגדרת על ידי אוסף מחרוזות‪ .‬כל‬
‫מחרוזת הוא שרשור של סמלים טרמינליים – מילים‪.‬‬
‫• שפת הלוגיקה מדרגה ראשונה ‪:first order logic‬‬
‫– סמלים טרמינליים‪~ V P , Q, :‬‬
‫– מחרוזות‪ Q V P :‬ולא ‪V P Q‬‬
‫• מה המבנה של שפה טבעית?‬
‫• דקדוק ‪ grammar‬הוא אוסף סופי של חוקים‬
‫המגדירים את השפה (למשל‪ ,‬שפות תכנות)‬
‫• לשפה טבעית – יש דקדוק‪ ,‬אבל מהו?‬
‫הבטים שונים בשפה‬
‫• סמנטיקה – הקשר בין התחביר לבין המשמעות‪.‬‬
‫– בשפת החשבון‪ – X+Y ,‬המשמעות‪ :‬חיבור בין ‪ X‬ל‪.Y-‬‬
‫• פרגמטיקה – משמעות המחרוזת המדוברת בתוך הקשר‪.‬‬
‫• צירופים ‪phrase structures‬‬
‫– צירופים שמניים‪ :‬הסוס הנהדר הזה‪ ,‬היריד‪ ,‬סוס כזה‪ ,‬כתם על‬
‫המצח‪.‬‬
‫– זיהוי צירופים מאפשר זיהוי משמעות (שמות עצם מתייחסים בד"כ‬
‫לישויות‪/‬אובייקטים בעולם)‪.‬‬
‫– צירופים מאפשרים לנו הגדרת המבנים האפשריים בשפה (למשל‬
‫– למה "רוץ אל היריד מהר" זה בעברית‪ ,‬אבל לא "אל רוץ מהר‬
‫היריד")‪.‬‬
‫הצעדים ביצירת התקשרות‬
‫•‬
‫•‬
‫•‬
‫•‬
‫•‬
‫כוונה ‪ –Intention‬הדובר ‪ S‬מחליט להגיד הגד‬
‫‪ (proposition) P‬לשומע ‪H‬‬
‫יצירה ‪ -Generation‬הפיכת ההיגד ‪ P‬למבע ‪utterance‬‬
‫כך שהשומע ‪ H‬שיקלוט את המבע בסיטואציה הנוכחית‪,‬‬
‫יוכל להסיק את משמעות ‪.P‬‬
‫סינתזה ‪ -Synthesis‬בכתב‪ ,‬בקול‪ ,‬או בכל דרך אחרת‪.‬‬
‫תפיסה ‪ H – Perception‬קולט את הנאמר ומזהה‬
‫‪speech recognition‬‬
‫ניתוח ‪ H -Analysis‬מסיק את המשמעויות האפשריות של‬
‫הנאמר‪:‬‬
‫– ניתוח תחבירי ‪(parsing‬פונקציה של ארגומנט אחד – המחרוזת)‬
‫– פירוש המשמעות ‪semantic interpretation‬‬
‫– פירוש פרגמטי ‪( pragmatic interpretation‬פונקציה של‬
‫המבע ושל ההקשר שבו נאמר)‬
‫יצירת משמעות ‪ -‬המשך‬
‫• ‪ – Disambiguation‬הסרת רב משמעות – מציאת‬
‫המשמעות שאליה כנראה התכוון הדובר‪.‬‬
‫• הכללה ‪ - incorporation‬האם ‪ H‬מאמין ל‪?P-‬‬
Speech/Character
Recognition
• Decomposition into words, segmentation
of words into appropriate phones or
letters
• Requires knowledge of phonological
patterns:
– I’m enormously proud.
– I mean to make you proud.
Bonnie Dorr ‫– השקפים הבאים של‬
Morphological Analysis
• Inflectional
– duck + s = [N duck] + [plural s]
– duck + s = [V duck] + [3rd person s]
• Derivational
– kind, kindness
• Spelling changes
– drop, dropping
– hide, hiding
Syntactic Analysis
• Associate constituent structure with
string
• Prepare for semantic interpretation
S
OR:
NP
I
VP
V
watched
watch
Subject
NP
det
I
Object
terrapin
N
Det
the terrapin
the
Semantics
• A way of representing meaning
• Abstracts away from syntactic
structure
• Example:
– First-Order Logic: watch(I,terrapin)
– Can be: “I watched the terrapin” or “The
terrapin was watched by me”
• Real language is complex:
– Who did I watch?
Lexical Semantics
The Terrapin, is who I watched.
Watch the Terrapin is what I do best.
*Terrapin is what I watched the
I= experiencer
Watch the Terrapin = predicate
The Terrapin = patient
Compositional Semantics
• Association of parts of a proposition with
semantic roles
• Scoping
Proposition
Experiencer
I (1st pers, sg)
Predicate: Be (perc)
pred
saw
patient
the
Terrapin
Word-Governed
Semantics
• Any verb can add “able” to form an
adjective.
– I taught the class . The class is teachable
– I rejected the idea. The idea is rejectable.
• Association of particular words with
specific semantic forms.
– John (masculine)
– The boys ( masculine, plural, human)
Pragmatics
• Real world knowledge, speaker
intention, goal of utterance.
• Related to sociology.
• Example 1:
– Could you turn in your assignments now (command)
– Could you finish the homework? (question,
command)
• Example 2:
– I couldn’t decide how to catch the crook. Then I
decided to spy on the crook with binoculars.
– To my surprise, I found out he had them too.
Then I knew to just follow the crook with
binoculars.
[ the crook [with binoculars]]
[ the crook] [ with binoculars]
Discourse Analysis
• Discourse: How propositions fit together
in a conversation—multi-sentence
processing.
• Pronoun reference:
– The professor told the student to finish the
assignment.
– He was pretty aggravated at how long it was
taking to pass it in.
NLP Pipeline
speech
text
Phonetic Analysis
OCR/Tokenization
Morphological analysis
Syntactic analysis
Semantic Interpretation
Discourse Processing
Relation to Machine
Translation
analysis
input
generation
output
Morphological analysis
Morphological synthesis
Syntactic analysis
Syntactic realization
Semantic Interpretation
Lexical selection
Interlingua
‫רב משמעות‬
Flying planes made her duck
1.the airplanes made her change her
position
2.the act of piloting made her change
her position
3.piloting turned her into a duck
4.the airplanes caused her duck (the
animal) to exist
5.the act of piloting made her duck
exist
‫רב משמעות תחבירית‬
)‫(מבנית‬
Structural ambiguity: •
S
NP
I
S
VP
V
NP
NP VP
made her
V
duck
I
VP
V
NP
made det N
her duck
part of ‫תיוג חלקי דיבר‬
speech tagging
• [verb Duck ] !
[noun Duck] is delicious for dinner
• I went to the bank to deposit my check.
I went to the bank to look out at the
river.
Resources for
NLP Systems
• Dictionary
• Morphology and Spelling Rules
• Grammar Rules
• Semantic Interpretation Rules
• Discourse Interpretation
Natural Language processing involves (1) learning
or fashioning the rules for each component, (2)
embedding the rules in the relevant automaton, (3)
and using the automaton to efficiently process the
input .
Some Applications
• Information Retrieval: Web search (uni-lingual
or multi-lingual)
• Question Answering/ Dialogue
• Report Generation: English/French weather
report
• Foreign Language Training: Spanish/Arabic
tutorial systems for military linguists
• Machine Translation : The Babelfish translation
system on Alta Vista
• Automatic “Essay evaluation”. Latent Semantic
indexing (Landauer et al)