SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
Pertemuan 5: WordNet, 8 November 2011
 WordNet
 Latihan
 Open Problems




                  WordNet – ISD312   NLTK dan Python   2
 Kamus, Tesaurus
 English
 Manually developed
 Hubungan antara kata
   synonym
   hyponym, hypernym
   meronym, holonym
   antonym




                         WordNet – ISD312   NLTK dan Python   3
 Menggunakan package nltk
   from nltk.corpus import wordnet as wn
 Mengakses synonym set (synset) sebuah kata
   wn.synsets('motorcar')
   wn.synset('car.n.01').lemma_names
   wn.synset('car.n.01').lemmas
   wn.synset('car.n.01').definition
   wn.synset('car.n.01').examples




                         WordNet – ISD312   NLTK dan Python   4
>>> from nltk.corpus import wordnet as wn
  >>> wn.synsets('motorcar')
  [Synset('car.n.01')]
 'motorcar' adalah anggota himpunan sinonim 'car.n.01'
 Anggota lain dari himpunan sinonim 'car.n.01'
  >>> wn.synset('car.n.01').lemma_names
  ['car', 'auto', 'automobile', 'machine', 'motorcar']




                           WordNet – ISD312   NLTK dan Python   5
 Lemma: nama synset dan kata
   synset: car.n.01
   kata: car
   lemma: car.n.01.car
 Mendapatkan semua lemma dari himpunan sinonim
 'car.n.01':
  >>> wn.synset('car.n.01').lemmas
  [Lemma('car.n.01.car'), Lemma('car.n.01.auto'),
    Lemma('car.n.01.automobile'),
  Lemma('car.n.01.machine'), Lemma('car.n.01.motorcar')]




                           WordNet – ISD312   NLTK dan Python   6
>>> wn.synset('car.n.01').definition
  'a motor vehicle with four wheels; usually propelled by
    an internal combustion engine'
  >>> wn.synset('car.n.01').examples
  ['he needs a car to get to work']

 atau
  >>> wn.lemmas('car')
  [Lemma('car.n.01.car'), Lemma('car.n.02.car'),
    Lemma('car.n.03.car'),
  Lemma('car.n.04.car'), Lemma('cable_car.n.01.car')]




                           WordNet – ISD312   NLTK dan Python   7
 Kata 'car' berada dalam synset berbeda
  >>> wn.synsets('car')
  [Synset('car.n.01'), Synset('car.n.02'),
    Synset('car.n.03'), Synset('car.n.04'),
  Synset('cable_car.n.01')]




                           WordNet – ISD312   NLTK dan Python   8
>>> for synset in wn.synsets('car'):
...   print synset.lemma_names
...
['car', 'auto', 'automobile', 'machine', 'motorcar']
['car', 'railcar', 'railway_car', 'railroad_car']
['car', 'gondola']
['car', 'elevator_car']
['cable_car', 'car']




                         WordNet – ISD312   NLTK dan Python   9
 Hubungan generic-specific
   animal, cat
   vehicle, bicycle
  >>> motorcar = wn.synset('car.n.01')
  >>> types_of_motorcar = motorcar.hyponyms()
  >>> len(types_of_motorcar)
  31
  >>> types_of_motorcar[26]
  Synset('ambulance.n.01')




                           WordNet – ISD312   NLTK dan Python   10
>>> sorted([lemma.name for synset in types_of_motorcar
  for lemma in synset.lemmas])
['Model_T', 'S.U.V.', 'SUV', 'Stanley_Steamer',
  'ambulance', 'beach_waggon',
...]




                         WordNet – ISD312   NLTK dan Python   11
>>> motorcar.hypernyms()
[Synset('motor_vehicle.n.01')]
>>> paths = motorcar.hypernym_paths()
>>> len(paths)
2
>>> [synset.name for synset in paths[0]]
['entity.n.01', 'physical_entity.n.01', 'object.n.01',
  'whole.n.02', 'artifact.n.01',
'instrumentality.n.03', 'container.n.01',
  'wheeled_vehicle.n.01',
'self-propelled_vehicle.n.01', 'motor_vehicle.n.01',
  'car.n.01']




                         WordNet – ISD312   NLTK dan Python   12
>>> [synset.name for synset in paths[1]]
  ['entity.n.01', 'physical_entity.n.01', 'object.n.01',
    'whole.n.02', 'artifact.n.01',
  'instrumentality.n.03', 'conveyance.n.03',
    'vehicle.n.01', 'wheeled_vehicle.n.01',
  'self-propelled_vehicle.n.01', 'motor_vehicle.n.01',
    'car.n.01']

 Root Hypernym
  >>> motorcar.root_hypernyms()
  [Synset('entity.n.01')]




                           WordNet – ISD312   NLTK dan Python   13
 Bagian dari 'tree' adalah 'trunk'
  >>> wn.synset('tree.n.01').part_meronyms()
  [Synset('burl.n.02'), Synset('crown.n.07'),
    Synset('stump.n.01'),
  Synset('trunk.n.01'), Synset('limb.n.02')]
  >>> wn.synset('tree.n.01').substance_meronyms()
  [Synset('heartwood.n.01'), Synset('sapwood.n.01')]
  >>> wn.synset('tree.n.01').member_holonyms()
  [Synset('forest.n.01')]




                             WordNet – ISD312   NLTK dan Python   14
>>> for synset in wn.synsets('mint', wn.NOUN):
... print synset.name + ':', synset.definition
...
batch.n.02: (often followed by `of') a large
  number or amount or extent
mint.n.02: any north temperate plant of the genus
  Mentha with aromatic leaves and
small mauve flowers
mint.n.03: any member of the mint family of plants
mint.n.04: the leaves of a mint plant used fresh
  or candied
mint.n.05: a candy that is flavored with a mint
  oil
mint.n.06: a plant where money is coined by
  authority of the government
                       WordNet – ISD312   NLTK dan Python   15
>>> wn.synset('mint.n.04').part_holonyms()
[Synset('mint.n.02')]
>>> wn.synset('mint.n.04').substance_holonyms()
[Synset('mint.n.05')]




                       WordNet – ISD312   NLTK dan Python   16
>>> wn.synset('walk.v.01').entailments()
[Synset('step.v.01')]
>>> wn.synset('eat.v.01').entailments()
[Synset('swallow.v.01'), Synset('chew.v.01')]
>>> wn.synset('tease.v.03').entailments()
[Synset('arouse.v.07'), Synset('disappoint.v.01')]




                       WordNet – ISD312   NLTK dan Python   17
>>> wn.lemma('supply.n.02.supply').antonyms()
[Lemma('demand.n.02.demand')]
>>> wn.lemma('rush.v.01.rush').antonyms()
[Lemma('linger.v.04.linger')]
>>>
  wn.lemma('horizontal.a.01.horizontal').antonyms(
  )
[Lemma('vertical.a.01.vertical'),
  Lemma('inclined.a.02.inclined')]
>>> wn.lemma('staccato.r.01.staccato').antonyms()
[Lemma('legato.r.01.legato')]




                       WordNet – ISD312   NLTK dan Python   18
 Synsets dihubungkan oleh lexical relations
 Diberikan sebuah synset, telusuri WordNet untuk
  menemukan synset yang mirip secara semantic
 Penting untuk membangun index
 Penting untuk mengolah kueri
 Kueri 'vehicle' mengambil juga dokumen tentang
  'limousine'




                          WordNet – ISD312   NLTK dan Python   19
 Semakin dekat path antara dua lemma, semakin mirip
 makna semantik kedua lemma tersebut
  >>>   right = wn.synset('right_whale.n.01')
  >>>   orca = wn.synset('orca.n.01')
  >>>   minke = wn.synset('minke_whale.n.01')
  >>>   tortoise = wn.synset('tortoise.n.01')
  >>>   novel = wn.synset('novel.n.01')




                           WordNet – ISD312   NLTK dan Python   20
>>> right.lowest_common_hypernyms(minke)
[Synset('baleen_whale.n.01')]
>>> right.lowest_common_hypernyms(orca)
[Synset('whale.n.02')]
>>> right.lowest_common_hypernyms(tortoise)
[Synset('vertebrate.n.01')]
>>> right.lowest_common_hypernyms(novel)
[Synset('entity.n.01')]




                       WordNet – ISD312   NLTK dan Python   21
>>>   wn.synset('baleen_whale.n.01').min_depth()
14
>>>   wn.synset('whale.n.02').min_depth()
13
>>>   wn.synset('vertebrate.n.01').min_depth()
8
>>>   wn.synset('entity.n.01').min_depth()
0




                         WordNet – ISD312   NLTK dan Python   22
>>> right.path_similarity(minke)
0.25
>>> right.path_similarity(orca)
0.16666666666666666
>>> right.path_similarity(tortoise)
0.076923076923076927
>>> right.path_similarity(novel)
0.043478260869565216




                       WordNet – ISD312   NLTK dan Python   23
 WordNet Bahasa Indonesia
 Thesaurus Bahasa Indonesia
    kateglo
 Membuat WordNet secara otomatis
   mengidentifikasi kemunculan bahasa gaul
   'sesuatu banget', 'rempong', 'jablay', 'lebay'
 VerbNet
    nltk.corpus.verbnet




                                WordNet – ISD312   NLTK dan Python   24
 Temukan semua senses dari kata 'dish'
   menurut penguasaan bahasa Inggris anda
   menurut cara yang dibahas di kelas




                            WordNet – ISD312   NLTK dan Python   25
 Soal nomor 27: The polysemy of a word is the number
 of senses it has. Using WordNet, we can determine
 that the noun dog has seven senses with
 len(wn.synsets('dog', 'n')). Compute the average
 polysemy of nouns, verbs, adjectives, and adverbs
 according to WordNet.




                          WordNet – ISD312   NLTK dan Python   26
 http://www.nltk.org/book
 KAmus, TEsaurus, dan GLOsarium,
  http://bahtera.org/kateglo
 http://www.sinonimkata.com/
 http://tjerdastangkas.blogspot.com/search/label/isd312




                             WordNet – ISD312   NLTK dan Python   27
 Lexical richness
 Perbandingan jumlah tokens dengan jumlah kata unik
   len(text1) / len(set(text1))
   Integer division
   from __future__ import division
 Jumlah kemunculan sebuah token
    text1.count('whale')
    100 * text1.count('whale') / len(text1)




                         WordNet – ISD312   NLTK dan Python   28
>>> def lexicalDiversity(text):
...     return len(text) / len(set(text))
>>> def percentage(count, total):
...     return 100 * count / total
lexicalDiversity(text5)
percentage(text1.count('whale'), len(text1))




                      WordNet – ISD312   NLTK dan Python   29

Más contenido relacionado

La actualidad más candente

Let'swift "Concurrency in swift"
Let'swift "Concurrency in swift"Let'swift "Concurrency in swift"
Let'swift "Concurrency in swift"Hyuk Hur
 
Rust: Reach Further
Rust: Reach FurtherRust: Reach Further
Rust: Reach Furthernikomatsakis
 
Implementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingImplementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingVincent Pradeilles
 
Intro to Rust from Applicative / NY Meetup
Intro to Rust from Applicative / NY MeetupIntro to Rust from Applicative / NY Meetup
Intro to Rust from Applicative / NY Meetupnikomatsakis
 
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونیMohammad Reza Kamalifard
 
Natural Language Toolkit (NLTK), Basics
Natural Language Toolkit (NLTK), Basics Natural Language Toolkit (NLTK), Basics
Natural Language Toolkit (NLTK), Basics Prakash Pimpale
 
GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)Gagan Agrawal
 
Teaching linked lists data structures using MIDI
Teaching linked lists data structures using MIDITeaching linked lists data structures using MIDI
Teaching linked lists data structures using MIDIMark Guzdial
 
The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181Mahmoud Samir Fayed
 
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando CoroutinesTDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutinestdc-globalcode
 
A Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeA Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeShakacon
 
Generics and Inference
Generics and InferenceGenerics and Inference
Generics and InferenceRichard Fox
 
Kotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is comingKotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is comingKirill Rozov
 
Design of bare metal proxy compute node
Design of bare metal proxy compute nodeDesign of bare metal proxy compute node
Design of bare metal proxy compute nodeLorin Hochstein
 
The Ring programming language version 1.10 book - Part 56 of 212
The Ring programming language version 1.10 book - Part 56 of 212The Ring programming language version 1.10 book - Part 56 of 212
The Ring programming language version 1.10 book - Part 56 of 212Mahmoud Samir Fayed
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my dayTor Ivry
 
10b. Graph Databases Lab
10b. Graph Databases Lab10b. Graph Databases Lab
10b. Graph Databases LabFabio Fumarola
 

La actualidad más candente (20)

Poly-paradigm Java
Poly-paradigm JavaPoly-paradigm Java
Poly-paradigm Java
 
Let'swift "Concurrency in swift"
Let'swift "Concurrency in swift"Let'swift "Concurrency in swift"
Let'swift "Concurrency in swift"
 
Rust: Reach Further
Rust: Reach FurtherRust: Reach Further
Rust: Reach Further
 
Implementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingImplementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional Programing
 
core.logic introduction
core.logic introductioncore.logic introduction
core.logic introduction
 
Intro to Rust from Applicative / NY Meetup
Intro to Rust from Applicative / NY MeetupIntro to Rust from Applicative / NY Meetup
Intro to Rust from Applicative / NY Meetup
 
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونی
 
Natural Language Toolkit (NLTK), Basics
Natural Language Toolkit (NLTK), Basics Natural Language Toolkit (NLTK), Basics
Natural Language Toolkit (NLTK), Basics
 
GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)
 
Teaching linked lists data structures using MIDI
Teaching linked lists data structures using MIDITeaching linked lists data structures using MIDI
Teaching linked lists data structures using MIDI
 
The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181
 
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando CoroutinesTDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
 
A Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeA Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts Bytecode
 
Generics and Inference
Generics and InferenceGenerics and Inference
Generics and Inference
 
Kotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is comingKotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is coming
 
Design of bare metal proxy compute node
Design of bare metal proxy compute nodeDesign of bare metal proxy compute node
Design of bare metal proxy compute node
 
The Ring programming language version 1.10 book - Part 56 of 212
The Ring programming language version 1.10 book - Part 56 of 212The Ring programming language version 1.10 book - Part 56 of 212
The Ring programming language version 1.10 book - Part 56 of 212
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my day
 
C++ L08-Classes Part1
C++ L08-Classes Part1C++ L08-Classes Part1
C++ L08-Classes Part1
 
10b. Graph Databases Lab
10b. Graph Databases Lab10b. Graph Databases Lab
10b. Graph Databases Lab
 

Destacado

Fall Fitness Challenge
Fall Fitness ChallengeFall Fitness Challenge
Fall Fitness ChallengeGreg Cox
 
O que é o Foto na Parede?
O que é o Foto na Parede?O que é o Foto na Parede?
O que é o Foto na Parede?Foto na Parede
 
Compramos la merienda 2º ciclo 2016
Compramos la merienda 2º ciclo 2016Compramos la merienda 2º ciclo 2016
Compramos la merienda 2º ciclo 2016XXX XXX
 
But Sales Was Not In My Job Description
But Sales Was Not In My Job DescriptionBut Sales Was Not In My Job Description
But Sales Was Not In My Job DescriptionDave Gee
 
Planetario 2º ciclo 2013
Planetario 2º ciclo 2013Planetario 2º ciclo 2013
Planetario 2º ciclo 2013XXX XXX
 
Investment decisions for pension funds by intangible value capital
Investment decisions for pension funds by intangible value capitalInvestment decisions for pension funds by intangible value capital
Investment decisions for pension funds by intangible value capitalJAYARAMAN IYER
 
Efficient Memory-Reference Checks for Real-time Java
Efficient Memory-Reference Checks for Real-time JavaEfficient Memory-Reference Checks for Real-time Java
Efficient Memory-Reference Checks for Real-time JavaAngelo Corsaro
 
Vortex: The Intelligent Data Sharing Platform for the Internet of Things
Vortex: The Intelligent Data Sharing Platform for the Internet of ThingsVortex: The Intelligent Data Sharing Platform for the Internet of Things
Vortex: The Intelligent Data Sharing Platform for the Internet of ThingsAngelo Corsaro
 
How Do You Measure The Power Of Words
How Do You Measure The Power Of WordsHow Do You Measure The Power Of Words
How Do You Measure The Power Of WordsPrashant Gandhi
 
Pe le projektin loppuarviointi
Pe le projektin loppuarviointiPe le projektin loppuarviointi
Pe le projektin loppuarviointiAija Hietanen
 
Real-Time Marketing With Twitter
Real-Time Marketing With TwitterReal-Time Marketing With Twitter
Real-Time Marketing With TwitterAsfaq Tapia
 
Blancanieves y los siete gigantones
Blancanieves y los siete gigantonesBlancanieves y los siete gigantones
Blancanieves y los siete gigantonesXXX XXX
 

Destacado (20)

Fall Fitness Challenge
Fall Fitness ChallengeFall Fitness Challenge
Fall Fitness Challenge
 
O que é o Foto na Parede?
O que é o Foto na Parede?O que é o Foto na Parede?
O que é o Foto na Parede?
 
ikd312-03-design
ikd312-03-designikd312-03-design
ikd312-03-design
 
Compramos la merienda 2º ciclo 2016
Compramos la merienda 2º ciclo 2016Compramos la merienda 2º ciclo 2016
Compramos la merienda 2º ciclo 2016
 
But Sales Was Not In My Job Description
But Sales Was Not In My Job DescriptionBut Sales Was Not In My Job Description
But Sales Was Not In My Job Description
 
OpenSplice Cache
OpenSplice CacheOpenSplice Cache
OpenSplice Cache
 
Planetario 2º ciclo 2013
Planetario 2º ciclo 2013Planetario 2º ciclo 2013
Planetario 2º ciclo 2013
 
Portfolio
PortfolioPortfolio
Portfolio
 
Beyond messaging
Beyond messagingBeyond messaging
Beyond messaging
 
Mintpad Pro
Mintpad ProMintpad Pro
Mintpad Pro
 
The Ride of Your Life
The Ride of Your LifeThe Ride of Your Life
The Ride of Your Life
 
MRLC MR/SR Oct 2016
MRLC MR/SR Oct 2016MRLC MR/SR Oct 2016
MRLC MR/SR Oct 2016
 
Investment decisions for pension funds by intangible value capital
Investment decisions for pension funds by intangible value capitalInvestment decisions for pension funds by intangible value capital
Investment decisions for pension funds by intangible value capital
 
Efficient Memory-Reference Checks for Real-time Java
Efficient Memory-Reference Checks for Real-time JavaEfficient Memory-Reference Checks for Real-time Java
Efficient Memory-Reference Checks for Real-time Java
 
Vortex: The Intelligent Data Sharing Platform for the Internet of Things
Vortex: The Intelligent Data Sharing Platform for the Internet of ThingsVortex: The Intelligent Data Sharing Platform for the Internet of Things
Vortex: The Intelligent Data Sharing Platform for the Internet of Things
 
How Do You Measure The Power Of Words
How Do You Measure The Power Of WordsHow Do You Measure The Power Of Words
How Do You Measure The Power Of Words
 
ikh311-08
ikh311-08ikh311-08
ikh311-08
 
Pe le projektin loppuarviointi
Pe le projektin loppuarviointiPe le projektin loppuarviointi
Pe le projektin loppuarviointi
 
Real-Time Marketing With Twitter
Real-Time Marketing With TwitterReal-Time Marketing With Twitter
Real-Time Marketing With Twitter
 
Blancanieves y los siete gigantones
Blancanieves y los siete gigantonesBlancanieves y los siete gigantones
Blancanieves y los siete gigantones
 

Similar a isd312-05-wordnet

5.1.3. Chord.pptx
5.1.3. Chord.pptx5.1.3. Chord.pptx
5.1.3. Chord.pptxAnusuya123
 
NS2-tutorial.ppt
NS2-tutorial.pptNS2-tutorial.ppt
NS2-tutorial.pptWajath
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript ObjectsReem Alattas
 
Declare Your Language: Type Checking
Declare Your Language: Type CheckingDeclare Your Language: Type Checking
Declare Your Language: Type CheckingEelco Visser
 
Introduction to Spark with Scala
Introduction to Spark with ScalaIntroduction to Spark with Scala
Introduction to Spark with ScalaHimanshu Gupta
 
Sumo, Simulation of Urban Mobility, (DLR, Open Source) tutorial
Sumo, Simulation of Urban Mobility, (DLR, Open Source) tutorial Sumo, Simulation of Urban Mobility, (DLR, Open Source) tutorial
Sumo, Simulation of Urban Mobility, (DLR, Open Source) tutorial Rodrigue Tchamna
 
Natural Language Processing and Python
Natural Language Processing and PythonNatural Language Processing and Python
Natural Language Processing and Pythonanntp
 

Similar a isd312-05-wordnet (10)

Ns2 introduction 2
Ns2 introduction 2Ns2 introduction 2
Ns2 introduction 2
 
5.1.3. Chord.pptx
5.1.3. Chord.pptx5.1.3. Chord.pptx
5.1.3. Chord.pptx
 
NS2-tutorial.ppt
NS2-tutorial.pptNS2-tutorial.ppt
NS2-tutorial.ppt
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Declare Your Language: Type Checking
Declare Your Language: Type CheckingDeclare Your Language: Type Checking
Declare Your Language: Type Checking
 
Xm lparsers
Xm lparsersXm lparsers
Xm lparsers
 
Introduction to Spark with Scala
Introduction to Spark with ScalaIntroduction to Spark with Scala
Introduction to Spark with Scala
 
Sumo, Simulation of Urban Mobility, (DLR, Open Source) tutorial
Sumo, Simulation of Urban Mobility, (DLR, Open Source) tutorial Sumo, Simulation of Urban Mobility, (DLR, Open Source) tutorial
Sumo, Simulation of Urban Mobility, (DLR, Open Source) tutorial
 
Natural Language Processing and Python
Natural Language Processing and PythonNatural Language Processing and Python
Natural Language Processing and Python
 
Ns network simulator
Ns network simulatorNs network simulator
Ns network simulator
 

Más de Anung Ariwibowo (20)

isd314-06-association-mining
isd314-06-association-miningisd314-06-association-mining
isd314-06-association-mining
 
ikp213-unifikasi
ikp213-unifikasiikp213-unifikasi
ikp213-unifikasi
 
ikp213-06-horn-clause
ikp213-06-horn-clauseikp213-06-horn-clause
ikp213-06-horn-clause
 
ikp213-01-pendahuluan
ikp213-01-pendahuluanikp213-01-pendahuluan
ikp213-01-pendahuluan
 
ikd312-05-sqlite
ikd312-05-sqliteikd312-05-sqlite
ikd312-05-sqlite
 
ikd312-05-kalkulus-relasional
ikd312-05-kalkulus-relasionalikd312-05-kalkulus-relasional
ikd312-05-kalkulus-relasional
 
ikd312-04-aljabar-relasional
ikd312-04-aljabar-relasionalikd312-04-aljabar-relasional
ikd312-04-aljabar-relasional
 
ikd312-02-three-schema
ikd312-02-three-schemaikd312-02-three-schema
ikd312-02-three-schema
 
ikp213-02-pendahuluan
ikp213-02-pendahuluanikp213-02-pendahuluan
ikp213-02-pendahuluan
 
ikh311-07
ikh311-07ikh311-07
ikh311-07
 
ikh311-06
ikh311-06ikh311-06
ikh311-06
 
ikh311-05
ikh311-05ikh311-05
ikh311-05
 
ikp321-svn
ikp321-svnikp321-svn
ikp321-svn
 
ikh311-04
ikh311-04ikh311-04
ikh311-04
 
ikp321-05
ikp321-05ikp321-05
ikp321-05
 
imsakiyah-jakarta-1433-09
imsakiyah-jakarta-1433-09imsakiyah-jakarta-1433-09
imsakiyah-jakarta-1433-09
 
ikh311-03
ikh311-03ikh311-03
ikh311-03
 
ikp321-04
ikp321-04ikp321-04
ikp321-04
 
ikp321-03
ikp321-03ikp321-03
ikp321-03
 
ikh311-02
ikh311-02ikh311-02
ikh311-02
 

Último

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 

Último (20)

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 

isd312-05-wordnet

  • 1. Pertemuan 5: WordNet, 8 November 2011
  • 2.  WordNet  Latihan  Open Problems WordNet – ISD312 NLTK dan Python 2
  • 3.  Kamus, Tesaurus  English  Manually developed  Hubungan antara kata  synonym  hyponym, hypernym  meronym, holonym  antonym WordNet – ISD312 NLTK dan Python 3
  • 4.  Menggunakan package nltk  from nltk.corpus import wordnet as wn  Mengakses synonym set (synset) sebuah kata  wn.synsets('motorcar')  wn.synset('car.n.01').lemma_names  wn.synset('car.n.01').lemmas  wn.synset('car.n.01').definition  wn.synset('car.n.01').examples WordNet – ISD312 NLTK dan Python 4
  • 5. >>> from nltk.corpus import wordnet as wn >>> wn.synsets('motorcar') [Synset('car.n.01')]  'motorcar' adalah anggota himpunan sinonim 'car.n.01'  Anggota lain dari himpunan sinonim 'car.n.01' >>> wn.synset('car.n.01').lemma_names ['car', 'auto', 'automobile', 'machine', 'motorcar'] WordNet – ISD312 NLTK dan Python 5
  • 6.  Lemma: nama synset dan kata  synset: car.n.01  kata: car  lemma: car.n.01.car  Mendapatkan semua lemma dari himpunan sinonim 'car.n.01': >>> wn.synset('car.n.01').lemmas [Lemma('car.n.01.car'), Lemma('car.n.01.auto'), Lemma('car.n.01.automobile'), Lemma('car.n.01.machine'), Lemma('car.n.01.motorcar')] WordNet – ISD312 NLTK dan Python 6
  • 7. >>> wn.synset('car.n.01').definition 'a motor vehicle with four wheels; usually propelled by an internal combustion engine' >>> wn.synset('car.n.01').examples ['he needs a car to get to work']  atau >>> wn.lemmas('car') [Lemma('car.n.01.car'), Lemma('car.n.02.car'), Lemma('car.n.03.car'), Lemma('car.n.04.car'), Lemma('cable_car.n.01.car')] WordNet – ISD312 NLTK dan Python 7
  • 8.  Kata 'car' berada dalam synset berbeda >>> wn.synsets('car') [Synset('car.n.01'), Synset('car.n.02'), Synset('car.n.03'), Synset('car.n.04'), Synset('cable_car.n.01')] WordNet – ISD312 NLTK dan Python 8
  • 9. >>> for synset in wn.synsets('car'): ... print synset.lemma_names ... ['car', 'auto', 'automobile', 'machine', 'motorcar'] ['car', 'railcar', 'railway_car', 'railroad_car'] ['car', 'gondola'] ['car', 'elevator_car'] ['cable_car', 'car'] WordNet – ISD312 NLTK dan Python 9
  • 10.  Hubungan generic-specific  animal, cat  vehicle, bicycle >>> motorcar = wn.synset('car.n.01') >>> types_of_motorcar = motorcar.hyponyms() >>> len(types_of_motorcar) 31 >>> types_of_motorcar[26] Synset('ambulance.n.01') WordNet – ISD312 NLTK dan Python 10
  • 11. >>> sorted([lemma.name for synset in types_of_motorcar for lemma in synset.lemmas]) ['Model_T', 'S.U.V.', 'SUV', 'Stanley_Steamer', 'ambulance', 'beach_waggon', ...] WordNet – ISD312 NLTK dan Python 11
  • 12. >>> motorcar.hypernyms() [Synset('motor_vehicle.n.01')] >>> paths = motorcar.hypernym_paths() >>> len(paths) 2 >>> [synset.name for synset in paths[0]] ['entity.n.01', 'physical_entity.n.01', 'object.n.01', 'whole.n.02', 'artifact.n.01', 'instrumentality.n.03', 'container.n.01', 'wheeled_vehicle.n.01', 'self-propelled_vehicle.n.01', 'motor_vehicle.n.01', 'car.n.01'] WordNet – ISD312 NLTK dan Python 12
  • 13. >>> [synset.name for synset in paths[1]] ['entity.n.01', 'physical_entity.n.01', 'object.n.01', 'whole.n.02', 'artifact.n.01', 'instrumentality.n.03', 'conveyance.n.03', 'vehicle.n.01', 'wheeled_vehicle.n.01', 'self-propelled_vehicle.n.01', 'motor_vehicle.n.01', 'car.n.01']  Root Hypernym >>> motorcar.root_hypernyms() [Synset('entity.n.01')] WordNet – ISD312 NLTK dan Python 13
  • 14.  Bagian dari 'tree' adalah 'trunk' >>> wn.synset('tree.n.01').part_meronyms() [Synset('burl.n.02'), Synset('crown.n.07'), Synset('stump.n.01'), Synset('trunk.n.01'), Synset('limb.n.02')] >>> wn.synset('tree.n.01').substance_meronyms() [Synset('heartwood.n.01'), Synset('sapwood.n.01')] >>> wn.synset('tree.n.01').member_holonyms() [Synset('forest.n.01')] WordNet – ISD312 NLTK dan Python 14
  • 15. >>> for synset in wn.synsets('mint', wn.NOUN): ... print synset.name + ':', synset.definition ... batch.n.02: (often followed by `of') a large number or amount or extent mint.n.02: any north temperate plant of the genus Mentha with aromatic leaves and small mauve flowers mint.n.03: any member of the mint family of plants mint.n.04: the leaves of a mint plant used fresh or candied mint.n.05: a candy that is flavored with a mint oil mint.n.06: a plant where money is coined by authority of the government WordNet – ISD312 NLTK dan Python 15
  • 17. >>> wn.synset('walk.v.01').entailments() [Synset('step.v.01')] >>> wn.synset('eat.v.01').entailments() [Synset('swallow.v.01'), Synset('chew.v.01')] >>> wn.synset('tease.v.03').entailments() [Synset('arouse.v.07'), Synset('disappoint.v.01')] WordNet – ISD312 NLTK dan Python 17
  • 18. >>> wn.lemma('supply.n.02.supply').antonyms() [Lemma('demand.n.02.demand')] >>> wn.lemma('rush.v.01.rush').antonyms() [Lemma('linger.v.04.linger')] >>> wn.lemma('horizontal.a.01.horizontal').antonyms( ) [Lemma('vertical.a.01.vertical'), Lemma('inclined.a.02.inclined')] >>> wn.lemma('staccato.r.01.staccato').antonyms() [Lemma('legato.r.01.legato')] WordNet – ISD312 NLTK dan Python 18
  • 19.  Synsets dihubungkan oleh lexical relations  Diberikan sebuah synset, telusuri WordNet untuk menemukan synset yang mirip secara semantic  Penting untuk membangun index  Penting untuk mengolah kueri  Kueri 'vehicle' mengambil juga dokumen tentang 'limousine' WordNet – ISD312 NLTK dan Python 19
  • 20.  Semakin dekat path antara dua lemma, semakin mirip makna semantik kedua lemma tersebut >>> right = wn.synset('right_whale.n.01') >>> orca = wn.synset('orca.n.01') >>> minke = wn.synset('minke_whale.n.01') >>> tortoise = wn.synset('tortoise.n.01') >>> novel = wn.synset('novel.n.01') WordNet – ISD312 NLTK dan Python 20
  • 21. >>> right.lowest_common_hypernyms(minke) [Synset('baleen_whale.n.01')] >>> right.lowest_common_hypernyms(orca) [Synset('whale.n.02')] >>> right.lowest_common_hypernyms(tortoise) [Synset('vertebrate.n.01')] >>> right.lowest_common_hypernyms(novel) [Synset('entity.n.01')] WordNet – ISD312 NLTK dan Python 21
  • 22. >>> wn.synset('baleen_whale.n.01').min_depth() 14 >>> wn.synset('whale.n.02').min_depth() 13 >>> wn.synset('vertebrate.n.01').min_depth() 8 >>> wn.synset('entity.n.01').min_depth() 0 WordNet – ISD312 NLTK dan Python 22
  • 23. >>> right.path_similarity(minke) 0.25 >>> right.path_similarity(orca) 0.16666666666666666 >>> right.path_similarity(tortoise) 0.076923076923076927 >>> right.path_similarity(novel) 0.043478260869565216 WordNet – ISD312 NLTK dan Python 23
  • 24.  WordNet Bahasa Indonesia  Thesaurus Bahasa Indonesia  kateglo  Membuat WordNet secara otomatis  mengidentifikasi kemunculan bahasa gaul  'sesuatu banget', 'rempong', 'jablay', 'lebay'  VerbNet  nltk.corpus.verbnet WordNet – ISD312 NLTK dan Python 24
  • 25.  Temukan semua senses dari kata 'dish'  menurut penguasaan bahasa Inggris anda  menurut cara yang dibahas di kelas WordNet – ISD312 NLTK dan Python 25
  • 26.  Soal nomor 27: The polysemy of a word is the number of senses it has. Using WordNet, we can determine that the noun dog has seven senses with len(wn.synsets('dog', 'n')). Compute the average polysemy of nouns, verbs, adjectives, and adverbs according to WordNet. WordNet – ISD312 NLTK dan Python 26
  • 27.  http://www.nltk.org/book  KAmus, TEsaurus, dan GLOsarium, http://bahtera.org/kateglo  http://www.sinonimkata.com/  http://tjerdastangkas.blogspot.com/search/label/isd312 WordNet – ISD312 NLTK dan Python 27
  • 28.  Lexical richness  Perbandingan jumlah tokens dengan jumlah kata unik  len(text1) / len(set(text1))  Integer division  from __future__ import division  Jumlah kemunculan sebuah token  text1.count('whale')  100 * text1.count('whale') / len(text1) WordNet – ISD312 NLTK dan Python 28
  • 29. >>> def lexicalDiversity(text): ... return len(text) / len(set(text)) >>> def percentage(count, total): ... return 100 * count / total lexicalDiversity(text5) percentage(text1.count('whale'), len(text1)) WordNet – ISD312 NLTK dan Python 29