Skip to content

Parsing (quickstart)

Luke Kader Belbina edited this page Mar 8, 2014 · 5 revisions

QuickStart (Parsing)

This quickstart was designed to get you up parsing poker hand-histories quickly.

Parser Example

    using HandHistories.Objects.GameDescription;
    using HandHistories.Objects.Hand;
    using HandHistories.Parser.Parsers.Factory;
    using HandHistories.Parser.Parsers.Base;

    public class ParserExample
    {
        public HandHistory ParseHand(SiteName site, string handText)
        {
            // Each poker site has its own parser so we use a factory to get the right parser.
            IHandHistoryParserFactory handHistoryParserFactory = new HandHistoryParserFactoryImpl();

            // Get the correct parser from the factory.
            IHandHistoryParser handHistoryParser = handHistoryParserFactory.GetFullHandHistoryParser(site);

            try
            {
                // The true causes hand-parse errors to get thrown. If this is false, hand-errors will
                // be silent and null will be returned.
                HandHistory handHistory = handHistoryParser.ParseFullHandHistory(handText, true);
                return handHistory;
            }
            catch (Exception ex) // Catch hand-parsing exceptions
            {
                Console.WriteLine("Parsing Error: {0}", ex.Message); // Example logging.
                return null;
            }
        }
    }

What's Parsed?

All HandHistory objects are inherited from the HandHistorySummary object. The parsed information contains:

  • Date hand played
  • Hand Id
  • Game description (site, limit, table size, game type, game variant, etc.)
  • A list of players (screen name, starting stack, seat number, known hole cards, etc)
  • A list of all the actions in the hand
  • Rake and pot-size
  • The community cards
  • Dealer button
  • Full hand-history text

For more information please take a look at the HandHistorySummary, HandHistory, objects:

Clone this wiki locally