Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
FM-index による全文検索
Search
Sho Iizuka
February 02, 2015
Programming
0
35
FM-index による全文検索
https://kujira16.hateblo.jp/entry/2015/02/06/210630
Sho Iizuka
February 02, 2015
Tweet
Share
More Decks by Sho Iizuka
See All by Sho Iizuka
半年前の自分に教えたい systemd のハマりどころ
arosh
19
17k
Osaka.Stan#5 LT プログラミングコンテストのデータを分析した話
arosh
1
6.9k
簡潔データ構造輪講資料(順列)
arosh
1
8.2k
Pythonにおける日本語処理
arosh
1
2.1k
円と円の外接線の求め方
arosh
0
67
円と円の交点の求め方
arosh
0
42
Other Decks in Programming
See All in Programming
decksh - a little language for decks
ajstarks
4
21k
実践 Dev Containers × Claude Code
touyu
1
240
パスタの技術
yusukebe
1
400
AHC051解法紹介
eijirou
0
620
LLMOpsのパフォーマンスを支える技術と現場で実践した改善
po3rin
8
980
自作OSでDOOMを動かしてみた
zakki0925224
1
1.4k
kiroでゲームを作ってみた
iriikeita
0
180
マイコンでもRustのtestがしたい その2/KernelVM Tokyo 18
tnishinaga
2
2.3k
State of CSS 2025
benjaminkott
1
120
Honoアップデート 2025年夏
yusukebe
1
840
モバイルアプリからWebへの横展開を加速した話_Claude_Code_実践術.pdf
kazuyasakamoto
0
240
あなたとJIT, 今すぐアセンブ ル
sisshiki1969
1
720
Featured
See All Featured
Producing Creativity
orderedlist
PRO
347
40k
Typedesign – Prime Four
hannesfritz
42
2.8k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
560
KATA
mclloyd
32
14k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
It's Worth the Effort
3n
187
28k
Mobile First: as difficult as doing things right
swwweet
223
9.9k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Transcript
FM-IndexʹΑΔશจݕࡧ ܭࢉػ࣮शE ࣗ༝՝
• จॻ͔ΒจࣈྻΛݕࡧ͢Δํ๏2௨ΓʹྨͰ͖Δ A. લॲཧ͕ෆཁͳํ๏ (ྗͤͳํ๏, KMP๏, BM๏) B. લॲཧ͕ඞཁͳํ๏ (సஔΠϯσοΫε,
ඌࣙྻ) • Bલॲཧͷ͕࣌ؒඞཁͳ͔ΘΓʹ, ಉ͡จॻ͔ΒԿճݕࡧ͢Δ߹AΑΓߴ • FM-IndexBʹྨ͞ΕΔํ๏Ͱ, จॻͷ͞ʹґଘ͠ͳ͍࣌ؒͰݕࡧͰ͖Δ
લॲཧ̍ɿඌࣙྻͷߏங จॻ mississippi mississippi$ ΤϯυϚʔΧ$ΛՃ mississippi$ ississippi$ ssissippi$ sissippi$ issippi$
ssippi$ sippi$ ippi$ ppi$ pi$ i$ $ ඌࣙͷྻڍ
લॲཧ̍ɿඌࣙྻͷߏங 0 mississippi$ 1 ississippi$ 2 ssissippi$ 3 sissippi$ 4
issippi$ 5 ssippi$ 6 sippi$ 7 ippi$ 8 ppi$ 9 pi$ 10 i$ 11 $ 11 $ 10 i$ 7 ippi$ 4 issippi$ 1 ississippi$ 0 mississippi$ 9 pi$ 8 ppi$ 6 sippi$ 3 sissippi$ 5 ssippi$ 2 ssissippi$ ࣙॻॱͰιʔτ͢Δ ※$ҙͷΞϧϑΝϕοτΑΓ ॱҐ͕খ͍͞ͱ͢Δ ඌࣙྻSA
લॲཧ̎ɿBWT (Burrows-Wheeler Transform) 11 $ 10 i$ 7 ippi$ 4
issippi$ 1 ississippi$ 0 mississippi$ 9 pi$ 8 ppi$ 6 sippi$ 3 sissippi$ 5 ssippi$ 2 ssissippi$ ݩͷจࣈྻʹ͓͚Δ ͻͱͭલͷจࣈʹ͢Δ i p s s m $ p i s s i i BWTจࣈྻT
ݕࡧॲཧ • BWTจࣈྻT = ipssm$pissii ʹ͍ͭͯ, ࣍ͷؔΛఆٛ͢Δ • Rank(c,p) :
T[0,p)ͷൣғͰ, ΞϧϑΝϕοτcͷग़ݱΛฦ͢ • RankLT(c) : TશମͰ, cΑΓॱҐ͕খ͍͞ ΞϧϑΝϕοτͷग़ݱΛฦ͢
ݕࡧॲཧ $ i$ ippi$ issippi$ ississippi$ mississippi$ pi$ ppi$ sippi$
sissippi$ ssippi$ ssissippi$ i p s s m $ p i s s i i BWTจࣈྻT ඌࣙྻSA
ݕࡧॲཧ $ i$ ippi$ issippi$ ississippi$ mississippi$ pi$ ppi$ sippi$
sissippi$ ssippi$ ssissippi$ i p s s m $ p i s s i i BWTจࣈྻT ඌࣙྻSA 'i'+"ppi$"ͷ ඌࣙྻ্Ͱͷ ग़ݱҐஔʁ
ݕࡧॲཧ $ i$ ippi$ issippi$ ississippi$ mississippi$ pi$ ppi$ sippi$
sissippi$ ssippi$ ssissippi$ i p s s m $ p i s s i i BWTจࣈྻT ඌࣙྻSA 'i'+"ppi$"ͷ ඌࣙྻ্Ͱͷ ग़ݱҐஔʁ
ݕࡧॲཧ $ i$ ippi$ issippi$ ississippi$ mississippi$ pi$ ppi$ sippi$
sissippi$ ssippi$ ssissippi$ i p s s m $ p i s s i i BWTจࣈྻT ඌࣙྻSA 'i'+"ppi$"ͷ ඌࣙྻ্Ͱͷ ग़ݱҐஔʁ LF-mapping c=T[p] ʹଓ͘จࣈྻͷ SA্Ͱͷग़ݱҐஔ RankLT(c)+Rank(c,p)
ݕࡧॲཧ $ i$ ippi$ issippi$ ississippi$ mississippi$ pi$ ppi$ sippi$
sissippi$ ssippi$ ssissippi$ i p s s m $ p i s s i i BWTจࣈྻT ඌࣙྻSA "ssi"ͷݕࡧ [RankLT('i')+Rank('i', 0), RankLT('i')+Rank('i', 12)) 'i'Ͱ࢝·Δ จࣈྻ
ݕࡧॲཧ $ i$ ippi$ issippi$ ississippi$ mississippi$ pi$ ppi$ sippi$
sissippi$ ssippi$ ssissippi$ i p s s m $ p i s s i i BWTจࣈྻT ඌࣙྻSA "ssi"ͷݕࡧ [RankLT('s')+Rank('s', 1), RankLT('s')+Rank('s', 5)) 's'+"i"Ͱ࢝·Δ จࣈྻ
ݕࡧॲཧ $ i$ ippi$ issippi$ ississippi$ mississippi$ pi$ ppi$ sippi$
sissippi$ ssippi$ ssissippi$ i p s s m $ p i s s i i BWTจࣈྻT ඌࣙྻSA "ssi"ͷݕࡧ [RankLT('s')+Rank('s', 8), RankLT('s')+Rank('s', 10)) 's'+"si"Ͱ࢝·Δ จࣈྻ
ݕࡧॲཧ • FM-index, ݕࡧจࣈྻʹରԠ͢ΔҐஔͷߜΓࠐΈΛ LF-mappingͷ܁Γฦ͠ʹΑͬͯߦ͏ • LF-mapping Rank ͱ RankLT
Ͱߦ͑Δ • ͜ͷ2ͭͷॲཧ, ΣʔϒϨοτΣʔϒϨοτߦྻΛ͑ O(log σ) ࣌ؒͰՄೳ (σ ΞϧϑΝϕοτͷछྨ) • LF-mappingΛݕࡧจࣈྻQͷ͚ͩ͞܁Γฦ͢ͷͰ, Ұճͷݕࡧ͕O(m log σ) ࣌ؒͰՄೳ (m Q ͷจࣈ) • ݕࡧ͕࣌ؒจॻͷ͞ʹґଘ͠ͳ͍
੍࡞ • ੨ۭจݿͰਓؾ͕͋Δਤॻ500Λରͱͨ͠ Σϒϒϥβ͔Β͑ΔΠϯΫϦϝϯλϧݕࡧΛ੍࡞ • ඌࣙྻͷߏஙsais.hxx (ߴͳϥΠϒϥϦ) Λ༻ • ΣʔϒϨοτߦྻͱFM-IndexࣗͰ࣮
(C++), boost-pythonʹΑΓPython༻ͷ֦ுϞδϡʔϧʹม • Flask (Web App Framework@Python) ͔Βݺͼग़͢
͏·͍͔͘ͳ͔ͬͨͱ͜Ζ • ͍͋·͍ݕࡧΛ࣮͠Α͏ͱͯ͠จݙΛ୳ͯ͠Έͨ → ฤूڑʹରͯ͠ࢦ͔͔࣌ؒΔΒ͍͠… • ࡞ͨ͠ࡧҾΛϑΝΠϧ͔ΒಡΈࠐΉॲཧͰ, طଘͷϥΠϒϥϦΛͬͨΒ༻ϝϞϦͷྔ͕രൃ (ݪҼෆ໌)
·ͱΊ • ߴͳจࣈྻݕࡧͷΞϧΰϦζϜΛ࣮ͯ͠Έͨ • ϒϥβ͔Β͑ΔΑ͏ʹͯ͠Έͨ ! • ࢀߟจݙ • Ԭݪ
େี. ߴจࣈྻղੳͷੈք. ؠॻళ. 2012.
(ิ) ΣʔϒϨοτ 3101212213 1000101101 10111 32223 10111 10001 ԼҐ2Ϗοτ →
ԼҐ1Ϗοτ → 0 1111 222 33 0 1 0 1 0 1