debaterpy package
Submodules
debaterpy.structures module
A collection of simple classes that store information. This is mostly a pythonic, class-based wrapper around DebaterJSON.
- class src.debaterpy.structures.Item
Bases:
object
A single item that is being stored, mostly used so that some default behaviour doesn’t need to be repeated as much.
- classmethod from_json(data: str) Item
Instantiates a new object based on the data contained in the json string
data
.
- to_json() str
Converts the object to a DebaterJSON string.
- class src.debaterpy.structures.Record(tournaments: list[Tournament], speaker_name: str | None = None)
Bases:
Item
The base class for one entire account of tournaments.
- speaker_name: str | None = None
The name of the speaker in this account.
- tournaments: list[Tournament]
The tournaments to include in this account
- class src.debaterpy.structures.Round(name: str | None = None, outround: bool | None = None, outround_category: str | None = None, prepped: bool | None = None, date: datetime | None = None, topics: list[str] | None = None, motion: str | None = None, infoslide: str | None = None, side: str | None = None, half: str | None = None, teammates: list[str] | None = None, speeches: list[Speech] | None = None, result: int | None = None, advanced: bool | None = None)
Bases:
Item
A single round that is associated with a tournament.
- advanced: bool | None = None
If the speaker advanced to the next phase of the tournament (if this round is an outround).
- date: datetime | None = None
The date at which this round took place.
- half: str | None = None
The half of the debate the debater was on. Only applies to BP.
- infoslide: str | None = None
The infoslide attached to the motion.
- motion: str | None = None
The motion of the round.
- name: str | None = None
The name of the round (e.g. ‘round 1’ or ‘grand finals’).
- outround: bool | None = None
If this round was an outround.
- outround_category: str | None = None
What speaker category this outround belongs to (e.g. open or ESL). Should only be used if the round is an outround.
- prepped: bool | None = None
Whether the round was a prepped round (if applicable).
- result: int | None = None
How many points the debater’s team got from this round. In two-team formats, a 1 or 0 simply mean a win or loss, respectively. For more complex formats, such as BP, please refer to the format’s manuals for how many points a certain result yields.
- side: str | None = None
The side of the motion the debater was on.
- teammates: list[str] | None = None
The teammate or teammates the speaker was debating with this round.
- topics: list[str] | None = None
Keywords relating to the topic of the debate (e.g. ‘Politics’).
- class src.debaterpy.structures.Speech(speech: int | None = None, speak: float | None = None)
Bases:
Item
A speech in a round.
- speak: float | None = None
The speak this speech received.
- speech: int | None = None
The speech of this speech. Only counts speeches on the debater’s side (e.g. in BP an opposition whip would be speech 4, not 8).
- class src.debaterpy.structures.Tournament(tournament_name: str, format: str | None = None, broke: bool | None = None, break_categories: list[str] | None = None, rounds: list[Round] | None = None)
Bases:
Item
A single tournament’s data. This is the primary object you will interact with the majority of the time.
- break_categories: list[str] | None = None
The category or categories the speaker broke in.
- broke: bool | None = None
Whether the debater broke at this tournament.
- format: str | None = None
The debating format used at this tournament (e.g. BP).
- classmethod from_dict(data: dict) Tournament
instantiate a new object based on the dictionary
data
.
- tournament_name: str
The name of the tournament.
debaterpy.utils module
Various utilities to aid in the manipulation and analysis of the objects in debaterpy.structures
.
- src.debaterpy.utils.generate_csv(record: Record, target: TextIOWrapper)
Writes a CSV representation of
record
totarget
.
- src.debaterpy.utils.get_all_rounds(record: ~src.debaterpy.structures.Record, function: ~typing.Callable[[~src.debaterpy.structures.Tournament, ~src.debaterpy.structures.Round], bool] = <function <lambda>>) Generator[Round, None, None]
Gets all the rounds
record
for whichfunction
returnsTrue
.This allows easier access to all the data such as for analysis of speaks or winrates. The
function
argument behaves similarly to Python’s built-infilter
, it only allows entries for whichfunction(x, y)
isTrue
. For example, the following code will get all rounds in BP (which might be useful for splitting up analyses by format):>>> get_all_rounds(record, lambda x, y: x.format == "BP") <generator object get_all_rounds at 0x102861e40>
- Parameters:
record – An instance of
structures.Record
from which the rounds will be extracted.function – A callable returning a boolean which needs to be true for a record to be included. Receives instances of
structures.Tournament
and ``structures.Round``as arguments. Will default to including all rounds.
- src.debaterpy.utils.get_all_speeches(record: ~src.debaterpy.structures.Record, function: ~typing.Callable[[~src.debaterpy.structures.Tournament, ~src.debaterpy.structures.Round, ~src.debaterpy.structures.Speech], bool] = <function <lambda>>) Generator[Speech, None, None]
Gets all speeches in
record
that satisfyfunction
.Functionally very similar to
get_all_rounds
. Thefunction
argument works to allow a filter to be applied to the speeches that are included.- Parameters:
record – An instance of
structures.Record
from which the speeches will be extracted.function – A callable returning a boolean which needs to be true for a record to be included. Receives instances of
structures.Tournament
,structures.Round
, andstructures.Speech
as arguments. Will default to including all speeches.
- src.debaterpy.utils.merge_records(*args: Record) Record
Merges all the records passed, tournament-wise.
Combines multiple records by their tournaments, creating one new
Record
object containing all the tournaments in the original records. Duplicate tournaments are identified byTournament.tournament_name
, meaning the same name will never show up twice in the record.If a tournament is in multiple records only the version of the tournament in the record that is passed first will be preserved (so if both the first and the second argument define a tournament called “WUDC 2022” only the one in the first argument will be used). Note that this could lead to the more complete record being discarded.