Skip to main content

No project description provided

Project description

qb-parser Documentation

qb-parser is a Python package for parsing the questions and answerlines in quizbowl. The answerline parser heavily borrows from qbreader's qb-answer-checker.

Installation

pip install qb-parser

Usage

clue_tokenize()

clue_tokenize() splits quizbowl questions into a list of clues just like nltk's sent_toknize(). It was written because the use of quotes and many periods (e.g. "Symphony No. 9") make quizbowl questions difficult for sent_tokenize().

AnswerLineParser

The AnswerLineParser is designed to parse answerlines containing directives and answers, and returning an Answer object. The answerline parser heavily borrows from qbreader's qb-answer-checker.

parse_answerline(self, answerline: str) -> Answer

  • Parameters:
    • answerline: A string containing directives and bracketed answers.
  • Returns: An Answer object containing organized directives and answers.

Example Usage

from qb_parser import AnswerLineParser
parser = AnswerLineParser()
answer = parser.parse_answerline("Adventure [accept {Microsoft Adventure} or {Colossal Cave Adventure}; accept {graphic adventures}; prompt on {graphic} with 'what other word is in the name of that genre?']")
print(answer)

Output

(<Directive.ACCEPT: 'accept'>, [('Adventure', ''), ('Microsoft Adventure', ''), ('Colossal Cave Adventure', ''), ('graphic adventures', ''), ('graphic adventure', '')])
(<Directive.REJECT: 'reject'>, [])
(<Directive.REGULAR_PROMPT: 'regular_prompt'>, [('graphic', 'what other word is in the name of that genre?')])
(<Directive.ANTIPROMPT: 'antiprompt'>, [])

Answer

The Answer class describes the answer for a quizbowl question. Internally, it uses a directive_map that, given a Directive (e.g. Directive.ACCEPT), produces a AnswerAction. AnswerAction contains a list of SingleAnswers that contain the answer_text and other useful properties like exact_directed_prompt.

Fields

  • directive_map: A dictionary mapping Directive types to AnswerAction objects.

Methods

  • getAnswerAction(self, directive: Directive) -> AnswerAction

    • Retrieves an AnswerAction based on the given Directive.
    • Parameters:
      • directive: A Directive enum value.
    • Raises:
      • ValueError if the directive is not found.
  • addAnswerAction(self, answerAction: AnswerAction)

    • Adds an AnswerAction to the corresponding directive in directive_map.
    • Parameters:
      • answerAction: An AnswerAction object to add.
    • Raises:
      • RuntimeError if the directive is invalid.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qb_parser-0.1.5.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qb_parser-0.1.5-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file qb_parser-0.1.5.tar.gz.

File metadata

  • Download URL: qb_parser-0.1.5.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.13 Linux/5.15.146.1-microsoft-standard-WSL2

File hashes

Hashes for qb_parser-0.1.5.tar.gz
Algorithm Hash digest
SHA256 db00c92d583bcdb63a8e1178ef793f5592a46ec8e56a319d14570903bf04b0a8
MD5 27d05f15855cbddc68fad5d2835dca5e
BLAKE2b-256 f4119e6a2eda71694c7d7792fe618d3dad33880b175fd4903c7dfdbb853fbd85

See more details on using hashes here.

File details

Details for the file qb_parser-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: qb_parser-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.13 Linux/5.15.146.1-microsoft-standard-WSL2

File hashes

Hashes for qb_parser-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7278d8e58236d0e5d8068672b60bde9e4bcd9a17b7115162701a5643c9ffeb0f
MD5 1c5ab8a43a1e7b0fc561321a35eca632
BLAKE2b-256 5d9f0307b2c4e26a4418b913835d21bb8b087a9f4326674e9e10a11449e0c999

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page