electorama / abif

The _Aggregated Ballot Information Format_ provides a concise, aggregated, text-based document to describe the ballots cast in range-based or ranked elections, as well as approval-based and choose-one balloting systems.
Other
4 stars 1 forks source link

Quoted tokens: allow double quotes, or always square brackets? #33

Open robla opened 1 year ago

robla commented 1 year ago

As I've been writing https://github.com/electorama/abiftool , it has occurred to me that double quotes make parsing a bit harder. The current test016.abif file looks like this:

# Case 16 - Bracketed candidate tokens (declared).  Ranked and scored.
#
# As of 2023-04-02, this test should pass, now that abif uses lark's builtin
# token "ESCAPED_STRING".

=DGM:[Doña García Márquez]
=SBJ:[Steven B. Jensen]
="蘇業":[Sue Ye (蘇業)]
=AM:[Adam Muñoz]

27: DGM/5 > SBJ/2 >  "蘇業"/1 > AM/0
26: SBJ/5 > DGM/3 =  "蘇業"/3 > AM/1
24:  "蘇業"/5 > DGM/2 =  AM/2 > SBJ/1
23:  AM/5 >  "蘇業"/3 > DGM/1 > SBJ/0

However, I was really tempted to change the file to this:

# Case 16 - Bracketed candidate tokens (declared).  Ranked and scored.
#
# As of 2023-04-02, this test should pass, now that abif uses lark's builtin
# token "ESCAPED_STRING".

=DGM:[Doña García Márquez]
=SBJ:[Steven B. Jensen]
=[蘇業]:[Sue Ye (蘇業)]
=AM:[Adam Muñoz]

27: DGM/5 > SBJ/2 >  [蘇業]/1 > AM/0
26: SBJ/5 > DGM/3 =  [蘇業]/3 > AM/1
24: [蘇業]/5 > DGM/2 =  AM/2 > SBJ/1
23:  AM/5 >  [蘇業]/3 > DGM/1 > SBJ/0

Note how the Chinese characters for our fictional "Sue Ye" candidate are surrounded by square brackets rather than doublequote marks in the latter example. I like the square brackets as a quoting mechanism because square brackets are much clearer about where the beginning and end are. However, I imagine in would be easier to take a CSV file and convert it to ABIF if double quotes are allowed, since many CSV files already use double quotes in addition to commas as column delimiters.

Thoughts? (my apologies if I've forgotten/misplaced a discussion of this point)