2018年5月7日月曜日

開発環境

入門 自然言語処理 (Steven Bird (著)、Ewan Klein (著)、Edward Loper (著)、萩原 正人 (翻訳)、中山 敬広 (翻訳)、水野 貴明 (翻訳)、オライリージャパン)の1章(言語処理とPython)、1.8(演習問題)15、16.を取り組んでみる。

コード(Emacs)

Python 3

#!/usr/bin/env python3

print('15.')
from nltk.book import *

words = sorted([word for word in set(text5) if word.startswith('b')])
for word in words:
    print(word)

print('16.')
r1 = range(10)
r2 = range(10, 20)
r3 = range(10, 20, 2)
r4 = range(20, 10, -2)
rs = [r1, r2, r3, r4]

for r in rs:
    for t in [r, list(r)]:
        print(t)
    print()

入出力結果(Terminal, Jupyter(IPython))

$ ./sample11.py
15.
*** Introductory Examples for the NLTK Book ***
Loading text1, ..., text9 and sent1, ..., sent9
Type the name of the text or sentence to view it.
Type: 'texts()' or 'sents()' to list the materials.
text1: Moby Dick by Herman Melville 1851
text2: Sense and Sensibility by Jane Austen 1811
text3: The Book of Genesis
text4: Inaugural Address Corpus
text5: Chat Corpus
text6: Monty Python and the Holy Grail
text7: Wall Street Journal
text8: Personals Corpus
text9: The Man Who Was Thursday by G . K . Chesterton 1908
b
b-day
b/c
b4
babay
babble
babblein
babe
babes
babi
babies
babiess
baby
babycakeses
bachelorette
back
backatchya
backfrontsidewaysandallaroundtheworld
backroom
backup
bacl
bad
bag
bagel
bagels
bahahahaa
bak
baked
balad
balance
balck
ball
ballin
balls
ban
band
bandito
bandsaw
banjoes
banned
baord
bar
barbie
bare
barely
bares
barfights
barks
barn
barrel
base
bases
basically
basket
battery
bay
bbbbbyyyyyyyeeeeeeeee
bbiam
bbl
bbs
bc
be
beach
beachhhh
beam
beams
beanbag
beans
bear
bears
beat
beaten
beatles
beats
beattles
beautiful
because
beckley
become
bed
bedford
bedroom
beeeeehave
beeehave
been
beer
before
beg
begin
behave
behind
bein
being
beleive
believe
belive
bell
belly
belong
belongings
ben
bend
benz
bes
beside
besides
best
bet
betrayal
betta
better
between
beuty
bf
bi
biatch
bible
biebsa
bied
big
bigest
biggest
biiiatch
bike
bikes
bikini
bio
bird
birfday
birthday
bisexual
bishes
bit
bitch
bitches
bitdh
bite
bites
biyatch
biz
bj
black
blade
blah
blank
blankie
blazed
bleach
blech
bless
blessings
blew
blind
blinks
bliss
blocking
bloe
blood
blooded
bloody
blow
blowing
blowjob
blowup
blue
blueberry
bluer
blues
blunt
board
bob
bodies
body
boed
boght
boi
boing
boinked
bois
bomb
bone
boned
bones
bong
boning
bonus
boo
booboo
boobs
book
boom
boooooooooooglyyyyyy
boost
boot
bootay
booted
boots
booty
border
borderline
bored
boredom
boring
born
born-again
bosom
boss
bossy
bot
both
bother
bothering
bottle
bought
bounced
bouncer
bouncers
bound
bout
bouts
bow
bowl
box
boy
boyfriend
boys
bra
brad
brady
brain
brakes
brass
brat
brb
brbbb
bread
break
breaks
breath
breathe
bred
breeding
bright
brightened
bring
brings
bro
broke
brooklyn
brother
brothers
brought
brown
brrrrrrr
bruises
brunswick
brwn
btw
bucks
buddyyyyyy
buff
buffalo
bug
bugs
buh
build
builds
built
bull
bulls
bum
bumber
bummer
bumped
bumper
bunch
bunny
burger
burito
burned
burns
burp
burpin
burps
burried
burryed
bus
buses
bust
busted
busy
but
butt
butter
butterscotch
button
buttons
buy
buying
bwahahahahahahahahahaha
by
byb
bye
byeee
byeeee
byeeeeeeee
byeeeeeeeeeeeee
byes
16.
range(0, 10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

range(10, 20)
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]

range(10, 20, 2)
[10, 12, 14, 16, 18]

range(20, 10, -2)
[20, 18, 16, 14, 12]

$

0 コメント:

コメントを投稿