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

Uploaded Python 3

File details

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

File metadata

  • Download URL: qb_parser-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 6c4df426852d41090323f07cca8d8bdcb750e45670940ea9514631523d8f3a38
MD5 5635642ecffda92ae2767bb01f5053d8
BLAKE2b-256 7b26d3a1f75cc07e313ce0c5651ae47821e3cb5b7838fe406b9603fc7e8ee63d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qb_parser-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b4f3680f14ac4be1ad76deec6cee33927fa0eeec7d45c4556db3b233c7727f6
MD5 fdce125440ba4698aca06836fdcc0ba8
BLAKE2b-256 91d0df040ba367f24b74ae868e1a5d667015179cc9e001e996a39f827ea073be

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