in reply to Parsing the Law
ie
The above is in no way final code, but that's the sort of approach I'd take.# use this in your rule tests for position my %structure = ( 1 => {qw(a b c d e f g h i etc...)}, 2 => {qw(1 2 3 4 5 6 7 8 9 10 11 12 13 etc...)}, 3 => {qw(A B C D E F G H I etc...)}, 4 => {qw(i ii iii iv v vi vii viii ix x xi etc...)} ); my %legalese; # hash to store text/markers my $key = 2; # key marker to keep order ('1' is tree root) # read into hash while (s/\((\w+)\)(.*?)(\(\w+\))/$3/s) { $legalese{$key}{'list_id'} = $1; $legalese{$key}{'content'} = $2; $key++; } my %node = ( 1 => ''); # node structure tree # initialise with single node # to denote top of page # now work on rules for tree depth my $last_node; # go through markers in order parsed in for (sort {$a <=> $b;} keys %legalese) { # too tired to try to create rule set :) # but set nodes as follows $node{$_}{'parent'} = 'whatever parent node is' # either '1', $last_node, or somewhere in between # using %structure as your guide $last_node = $_; }
Hope that's enough pointers. By knowing what type the previous node was, you can create a valid rule for the next node by asking:
cLive ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Parsing the Law
by swiftone (Curate) on May 30, 2001 at 01:00 UTC |