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

Uploaded Python 3

File details

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

File metadata

  • Download URL: qb_parser-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 ae9c901e620ad24bc6bbb0d14d3b5af55be36f96fd6184a2f25288652ef52296
MD5 79a1b0d5e13a9876ce6a210f6e33e8ec
BLAKE2b-256 6ef69c130dfe99ccad80e3bcb4e318fa84990e8feeac3ea25546f8909574cab9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qb_parser-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 508ead816bb9e1e567e1d94391c52fa541e6e2ad2deeb33bb504193e4b956d42
MD5 bb88e10276201e1ab7c82fc11834896c
BLAKE2b-256 29ad7216778a298dcc336a69e91657c7fa5238725869e526a642c697177ed71b

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