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.2.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.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qb_parser-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 527e7a6751b99246f94109df100f1dbe8ebd53015ba92fdfa7ab587c3543aa1a
MD5 531a0a69b9bad81614ea7047a6843960
BLAKE2b-256 6bb33ef5ca944ce82b36e872be7ff007b72cf9b56356d348e527550ed72198de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qb_parser-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 57fbecdf06c4ba7bb215ab5a2cb392b7c7f6cf3dd9d070bae796390291d0d17a
MD5 c082a75121f38bb8e4a243e8f3a30cc0
BLAKE2b-256 0d76c879759eb22863c345b6ce24200a2993dbdde3574b76a32c9daf7d575b6a

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