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

Uploaded Python 3

File details

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

File metadata

  • Download URL: qb_parser-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 d818ab66ca79a18ad8045887eebc9a95d51c10eacd51e5d43dd13617fb66c45c
MD5 3a756812408b76fe441db3cb991817fe
BLAKE2b-256 5b64bf5a97f44b577938413066605676ae488017472f611ffd3bc26b753abc88

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qb_parser-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6ec72ff66f91c247c37b16a3e0eb2726e75bcb426e08e3f8f9e90f786e650ecf
MD5 6bc0d3c8e9a1efa362c73453084aff1e
BLAKE2b-256 d4ecc91317f8fe74585abbe8ce4487a0f4123408ec51c840a04284743bd8cb49

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