Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
B3 コアタイム 第2回目 ( 2014年11月25日(火) )
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
yoshii25
November 25, 2014
Education
81
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
B3 コアタイム 第2回目 ( 2014年11月25日(火) )
yoshii25
November 25, 2014
Transcript
25 slides
B3ίΞλΠϜ (201411݄25(Ր)) ʰೖ ࣗવݴޠॲཧʱ ɹɹ1ষ ݴޠॲཧͱPython Ԭٕज़Պֶେֶ ࣗવݴޠॲཧݚڀࣨ B3 ழມ
ܚथ
ςʔϚ
ςʔϚ ❖ PythonͷπʔϧͱςΫχοΫ ❖ NLTKͷ༻ํ๏ ❖ ؆୯ͳ౷ܭॲཧ
Python
Python ❖ Pythonͷར ❖ ߏจҙຯͷཧղ͕ฏқ ❖ จࣈྻΛऔΓѻ͏͕ؔ๛ ❖ Pythonͷಛ ❖
มͷܕͷએݴ͕ෆཁ ❖ ߏจʹΠϯσϯτΛ༻͢Δ https://www.python.org/community/logos/
NLTK
NLTK ❖ ࢺͷλά͚, ߏจղੳ, ςΩε τͷྨͱ͍ͬͨॲཧΛߦ͏Πϯ λʔϑΣΠε ❖ ෳࡶͳΛղͨ͘ΊʹΈ߹Θ ͤΔ͜ͱ͕Ͱ͖Δ࣮
Natural Language Toolkit
༻͢Δલʹ ❖ NLTKͷΠϯϙʔτ ❖ >>> import nltk ❖ ςΩετͷΠϯϙʔτ ❖
>>> from nltk.book import *
NLTKͷػೳ ❖ ςΩετͷݕࡧ ❖ >>> text.concordance(“hoge1”) ❖ >>> text.concordance([“hoge1”, “hoge2”])
❖ ୯ޠΛ͑Δ ❖ >>> text.count(“hoge”)
NLTKͷػೳ ❖ ޠኮΛ͑Δ ❖ >>> len(text) ❖ ޠኮͷऔಘ ❖ >>>
set(text) ❖ ޠኮͷιʔτ ❖ >>> sorted(set(text))
NLTKͷػೳ ❖ ؔͷఆٛ ❖ ྫ) ςΩετͷޠኮͷ๛͞ ❖ >>> def function(text)
: ❖ . . . return len(text) / len(set(text))
Python ͖ͭͮ
Pythonͷػೳ ❖ Ϧετ ❖ ςΩετͳͲΛऩೲ͢ΔྻͷΑ͏ͳͷ. ❖ >>> sent[“hoge1”, “hoge2”, “hoge3”,
“hoge4”]
Ϧετ ❖ Ϧετͷ࿈݁ ❖ >>> sent1[“hoge1”, “hoge2”] + sent2[“hoge3”, “hoge4”]
❖ ϦετͷՃ ❖ >>> sent.append(“hoge”) ❖ εϥΠγϯά ❖ >>> sent[5 : 8]
Pythonͷػೳ ❖ จࣈྻ ❖ Ճࢉ, ࢉͳͲՄೳ. ࿈݁, ׂͷػೳΛ࣋ͭ. ❖ name
= ‘Hoge’
จࣈྻ ❖ จࣈྻͷ࿈݁ ❖ >>> ‘ ‘ .join([‘Hoge1’, ‘Hoge2’]) ❖
จࣈྻͷׂ ❖ >>> ‘Hoge1 Hoge2’.split()
Pythonͷػೳ ❖ ݅ࣜ ❖ ༻๏Cݴޠͱ΄΅ಉ༷. ൣғΛΠϯσϯτͰஅ. ❖ >>> if len(word)
< 5 ❖ . . . print ‘word length is less then 5’
݅ࣜ ❖ ୯ޠൺֱʹ͑Δԋࢉࢠ ❖ s.startswitch(t) s ͕ t Ͱ࢝·Δ͔Ͳ͏͔ ❖
s.endswitch(t) s ͕ t ͰऴΘΔ͔Ͳ͏͔ ❖ t in sɹɹɹɹɹ s ͷதʹ t ؚ͕·ΕΔ͔Ͳ͏͔ ❖ s.islower() s ͷதʹେจࣈؚ͕·Ε͍ͯͳ͍ ❖ s.isupper() s ͷதʹࢠจࣈؚ͕·Ε͍ͯͳ͍ ❖ s.isalpha() s ͷதͷจࣈ͕શͯΞϧϑΝϕοτ͔Ͳ͏͔ ❖ s.isalnum() s ͷதͷจࣈ͕શͯΞϧϑΝϕοτ͘͠ࣈ͔Ͳ͏͔
݅ࣜ ❖ ୯ޠൺֱʹ͑Δԋࢉࢠ ͖ͭͮ ❖ s.isdigit() s ͷதͷจࣈ͕શͯࣈ͔Ͳ͏͔ ❖ s.istitle()
s ͕λΠτϧέʔε͔Ͳ͏͔
Pythonͷػೳ ❖ ݅ذ ❖ ༻๏Cݴޠͱ΄΅ಉ༷. ಉ͘͡ൣғΛΠϯσϯτͰஅ. ❖ >>> for i
in range(10) ❖ . . . print i
؆୯ͳ౷ܭॲཧ
؆୯ͳ౷ܭॲཧ ❖ සग़͢Δ୯ޠΛऔΓग़͢ ❖ >>> fdist1 = FreqDist(text) ❖ ςΩετதͷҟͳΓޠΛऔΓग़͢
❖ >>> vocaburaly1 = fdist1.keys()
؆୯ͳ౷ܭॲཧ ❖ ςΩετͷ༰Λද͢୯ޠΛऔΓग़͍ͨ͠. ❖ → औΓग़ͨ͠୯ޠ͔ΒςΩετͷ༰͕ཧղͰ͖Δʂ
؆୯ͳ౷ܭॲཧ ❖ ‘,’ ‘the’, ‘.’, ‘and’ͳͲจࣈ͕͍୯ޠ͕සग़͢ΔͳΒ, 1ճ͠ ͔ొ͠ͳ͍୯ޠΛ୳ͤΑ͍ͷͰʁ ❖
15จࣈҎ্ͷ୯ޠΛऔΓग़͢ ❖ >>> V = set(text1) ❖ . . . long_words = [w for w in V if len(w) > 15]
؆୯ͳ౷ܭॲཧ ❖ 1ճ͔͠ొ͠ͳ͍୯ޠ,จ຺͔Βཧղ͠ͳ͚ΕͳΒͳ͍୯ޠ͕ ଟ͘, ςΩετͷ༰ཧղͰ͖ͳ͍. ❖ 7จࣈҎ্, 7ճҎ্ొͨ͠୯ޠΛऔΓग़͢ ❖ >>>
fdist5 = FreqDist(text5) ❖ >>> sorted([w for w in set(text5) if len > 7 and fdist5[w] > 7])
More Decks by yoshii25
See All by yoshii25
文献紹介 (05/13/2016)
yoshii25
0
120
文献紹介 ( 02/18/2016 )
yoshii25
0
200
文献紹介 ( 2015年7月8日(水) )
yoshii25
0
190
文献紹介 ( 2015年6月10日(水) )
yoshii25
0
200
文献紹介 ( 2015年5月12日(火) )
yoshii25
0
200
文献紹介 ( 2015年4月1日(水) )
yoshii25
0
230
B3 勉強会 第12回目 ( 2015年3月26日(木) )
yoshii25
0
190
B3 勉強会 第10回目 ( 2015年3月13日(金) )
yoshii25
0
190
B3 勉強会 第8回目 ( 2015年2月20日(金) )
yoshii25
0
220
Other Decks in Education
See All in Education
[2026後期火5] 論理学(京都大学文学部 後期 第1回)「名前はあるのに、誰なのかわからない」
yatabe
0
220
Session 4 - Teknik Lobby dan Negosiasi
adeputra13
0
1k
Padlet opetuksessa
matleenalaakso
12
16k
LP2627
cbtlibrary
0
220
Session 3 - Mass Communication
adeputra13
0
750
Zimmerman "Copyright Essentials From A to AI: A 2026 NISO Training Series, Session Seven: Copyright & AI"
baltimoreniso
0
130
Concours Photo - UGE - 2026
echaille
0
200
2026年度秋学期 統計学 第7回 データの関係を知る(2)ー回帰と決定係数 (2026. 11. 17)
akiraasano
PRO
0
290
Image processing with PDEs
hachama
0
560
Session 7 - Mass Communication
adeputra13
0
920
Web 2.0 Patterns and Technologies - Lecture 8 - Web Technologies (1019888BNR)
signer
PRO
0
3.5k
Sekolah Sabat - Triwulan 4 2026 - Pelajaran 3
hiola
0
7.3k
Featured
See All Featured
First, design no harm
axbom
PRO
2
1.4k
Making Projects Easy
brettharned
120
6.9k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
590
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
3k
Building AI with AI
inesmontani
PRO
1
1.4k
エンジニアに許された特別な時間の終わり
watany
109
250k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.8k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.9k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.6k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
320
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.3k