eregs / regulations-parser

Parser for U.S. federal regulations and other regulatory information
Creative Commons Zero v1.0 Universal
37 stars 39 forks source link

Command: outline_depths #343

Closed dogweather closed 7 years ago

dogweather commented 7 years ago

Providing access to derive_depths to other apps. In my case, I'd like to use it from Ruby on Rails.

dogweather commented 7 years ago

@cmc333333 what do you think — I just found that I get errors, e.g.:

Input: 'a b c i ii iii d e i'

Alternates between two different outputs: 0 0 0 1 1 1 0 0 0 (wrong) and 0 0 0 1 1 1 0 0 1 (correct).

(I'm simply taking one of the returned solutions, so I get it that the function is returning two. Seems to me, though, that it shouldn't. I.e., the final i can only be roman ... assuming a full, correct outline.)

dogweather commented 7 years ago

Is there a "strict mode" kind of setting?

cmc333333 commented 7 years ago

Thanks @dogweather! Regs will sometimes skip paragraphs, so that's a correct potential set of indentations. We allow the depth derivation to be configured for exactly this sort of scenario, though, by using the second parameter to derive_depths. To disallow any gaps between paragraph markers, set the last parameter to the [limit_sequence_gap(1)] rule (we default to 3 when parsing regtext).

Also, let us know if you need any help with the linting errors. Here's the suggestion for type hints which need to be read by interpreters prior to 3.5.

dogweather commented 7 years ago

Type annotations w/ 2.7 compatibility looks like a murky pain. I'll remove it.

cmc333333 commented 7 years ago

Just a line-length linting error left. Happy to resolve if you give the org edit rights on this PR.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.03%) to 91.738% when pulling fe4addf665c1bf84fdc917aa68ffbc23f6d53efa on dogweather:command-derive-depths into 0d1c784708b2df0551edf71cf20977dfbb5b6fd6 on eregs:master.

cmc333333 commented 7 years ago

This'll be a useful feature, thanks @dogweather!