2009-04-25 27 views
4

Ich möchte eine Rails App schreiben, die mir bei meinem Online Poker hilft. Ich spiele auf PokerStars, und für jede gespielte Hand sind Textdaten verfügbar. Das Format es in kommt, ist dies:Parsing in Ruby (on Rails)

PokerStars Game #27457662450: Tournament #157033867, Freeroll Hold'em No Limit - Level IV (50/100) - 2009/04/24 20:39:44 ET 
Table '157033867 830' 9-max Seat #1 is the button 
Seat 1: DortheaV (7624 in chips) 
Seat 2: Currly234 (3016 in chips) 
Seat 3: paolilla (3086 in chips) 
Seat 4: triumph888 (1571 in chips) is sitting out 
Seat 5: Minchausti (1185 in chips) is sitting out 
Seat 6: madmike11847 (1195 in chips) is sitting out 
Seat 7: alamodey (4038 in chips) 
Seat 8: whiskerbob (3365 in chips) 
Seat 9: SHpic76 (1115 in chips) is sitting out 
DortheaV: posts the ante 10 
Currly234: posts the ante 10 
paolilla: posts the ante 10 
triumph888: posts the ante 10 
Minchausti: posts the ante 10 
madmike11847: posts the ante 10 
alamodey: posts the ante 10 
whiskerbob: posts the ante 10 
SHpic76: posts the ante 10 
Currly234: posts small blind 50 
paolilla: posts big blind 100 
*** HOLE CARDS *** 
Dealt to alamodey [8s Ks] 
triumph888: folds 
Minchausti: folds 
madmike11847: folds 
alamodey: calls 100 
whiskerbob: folds 
SHpic76: folds 
DortheaV: folds 
Currly234: calls 50 
paolilla: checks 
*** FLOP *** [5c 4h 6d] 
Currly234: checks 
paolilla: checks 
alamodey: bets 234 
Currly234: folds 
paolilla: folds 
Uncalled bet (234) returned to alamodey 
alamodey collected 390 from pot 
alamodey: doesn't show hand 
*** SUMMARY *** 
Total pot 390 | Rake 0 
Board [5c 4h 6d] 
Seat 1: DortheaV (button) folded before Flop (didn't bet) 
Seat 2: Currly234 (small blind) folded on the Flop 
Seat 3: paolilla (big blind) folded on the Flop 
Seat 4: triumph888 folded before Flop (didn't bet) 
Seat 5: Minchausti folded before Flop (didn't bet) 
Seat 6: madmike11847 folded before Flop (didn't bet) 
Seat 7: alamodey collected (390) 
Seat 8: whiskerbob folded before Flop (didn't bet) 
Seat 9: SHpic76 folded before Flop (didn't bet)

Gibt es Parsen Bibliotheken für Ruby oder muss ich dies manuell tun und hackily?

Antwort

2

Das klingt nach einem Job für Regex !. Ich bezweifle, dass die Verwendung einer Bibliothek es einfacher machen würde, zu parsen, da es ein ziemlich benutzerdefiniertes Format ist, das man einfach weghacken muss.

1

Ragel ist sehr gut, einen Parser zu schreiben. Z.B. Der http-Parser von Mongrel wird mit ragel erzeugt.

1

Auch wenn Sie nur die Daten möchten, sollten Sie einfach PokerTracker auschecken. PokerTracker speichert 100% der Handinformationen und verfügt über ein gut dokumentiertes Schema und eine offene PostgreSQL-Datenbank.