diff --git a/README.md b/README.md index 33c6fc9..2647cc8 100644 --- a/README.md +++ b/README.md @@ -123,11 +123,12 @@ The options are: -H: Print an HTML calendar of this month -h: set the home person - useful for calculating relationships with -d -i: creates an ICS file + -l: include living people + -L: include ged2site hyperlinks with -H -m: month for -H calendar -M: produce a map of a place (currently only Kent is supported) as an animated gif of births into $surname.gif - -l: include living people - -L: include ged2site hyperlinks with -H + -O: print a list of occupations, useful for finding typoes and inconsistencies -p: print the biography of the given person -t: print tomorrow's information, don't use with -a -T: print a list of towns, useful for finding typos and inconsistencies diff --git a/gedcom b/gedcom index 2d0fff6..9c0c124 100755 --- a/gedcom +++ b/gedcom @@ -189,7 +189,7 @@ use Array::Iterator::BiDirectional; sub get_location($); my %opts; -getopts('aAbB:cCdDe:fFGgh:Hi:m:M:lLp:sStTwWxvy:', \%opts); +getopts('aAbB:cCdDe:fFGgh:Hi:m:M:lLOp:sStTwWxvy:', \%opts); die "Usage: $0 [ -a ] [ -A ] [ -b ] [ -B book.pdf ] [ -c ] [ -C ] [ -d ] [ -D ] [ -f ] [ -F ] [ -G ] [ -h home-person-name ] [ -H [ -L [ -e ] ] [ -i ics_file ] [ -M place ] [ -m month ] [ -y year ] ] [ -l ] [ -p person-to-print ] [ -s ] [ -S ] [ -t ] [ -T ] [ -w [ -W ] [ -g | -x ]] filename [ filename2 ]" unless($ARGV[0]); print "Starting\n" if($opts{'v'}); @@ -202,6 +202,7 @@ my %places; my %all_locations; my %all_places; my %all_residences; +my %all_occupations; # my $pi = atan2(1,1) * 4; # binmode(STDOUT, ':utf8'); @@ -260,7 +261,7 @@ if($opts{'B'}) { 'NJH::PDFPage' ,'LWP::Simple::WithCache', 'PDF::API2', 'PDF::API2::XS', 'Text::Soundex', 'Text::Wrap'; -} elsif($opts{'T'} || $opts{'i'}) { +} elsif($opts{'T'} || $opts{'i'} || $opts{'O'}) { if($opts{'i'}) { push @modules, 'Data::ICal', 'Date::ICal', 'Data::ICal::Entry::Event', @@ -275,7 +276,7 @@ if($opts{'B'}) { } else { push @modules, 'GIS::Distance'; } -unless($opts{'T'} && !$opts{'v'}) { +unless(($opts{'T'} || $opts{'O'}) && !$opts{'v'}) { push @modules, 'Geo::Coder::List', 'Geo::Coder::Free', 'Geo::Coder::Free::Local', 'Geo::Coder::CA', 'Geo::Coder::Postcodes', # 'Geo::Coder::DataScienceToolkit', @@ -585,7 +586,7 @@ if($opts{'v'}) { my $geocoder; my $textgeocoder; -if((!$opts{'T'}) || $opts{'v'}) { +if(((!$opts{'T'}) && (!$opts{'O'})) || $opts{'v'}) { $geocoder = Geo::Coder::List->new($gopts)->push(Geo::Coder::Free::Local->new()); my %topts; @@ -800,7 +801,7 @@ if($opts{'x'}) { } elsif($opts{'g'} || $opts{'M'}) { $opts{'T'} = 1; } -if($opts{'T'}) { +if($opts{'T'} || $opts{'O'}) { $opts{'A'} = $opts{'a'} = $opts{'d'} = 1; } my $ical; @@ -848,7 +849,7 @@ if($opts{'w'}) { my $meteo; -if($opts{'d'} && !$opts{'T'}) { +if($opts{'d'} && (!$opts{'T'}) && (!$opts{'O'})) { $meteo = Weather::Meteo->new(ua => $cached_browser); } @@ -1233,6 +1234,9 @@ if($opts{'H'}) { system("apngasm output.png frame*.png 3 4 && apng2gif output.png $surname.gif"); } unlink 'output.png', @files; + } elsif($opts{'O'}) { + generate(everyone => \@everyone, dbh => $dbh); + dump_occupations(\%all_occupations); } else { generate(everyone => \@everyone, dbh => $dbh); dump_places(\%all_places); @@ -2068,6 +2072,12 @@ sub print_person dump_geocoder_log(); + return; + } elsif($opts{'O'}) { + foreach my $occupation(get_all_occupations($person)) { + push @{$all_occupations{$occupation}}, $person; + } + return; } else { print $person->as_string($args), "\n"; @@ -8900,6 +8910,8 @@ sub year sub place { my %params = (ref($_[0]) eq 'HASH') ? %{$_[0]} : @_; + return if($opts{'O'}); + my $place = $params{'place'}; my $address = $params{'address'}; @@ -10435,6 +10447,11 @@ sub get_all_occupations $occupations[0] =~ tr/\n/ /; $occupations[0] =~ s/\.+$//; + if(($occupations[0] =~ /(.+)\sdomestic$/i) || + ($occupations[0] =~ /(.+)\sdom$/i)) { + $occupations[0] = "Domestic $1"; + } + if($occupations[0] =~ /works? on (.+)/i) { $occupations[0] = "$1 worker"; } elsif(($occupations[0] eq 'Ag Lab') || @@ -10542,12 +10559,11 @@ sub get_all_occupations $occupations[0] =~ s/[\(\)]//g; $occupations[0] =~ s/\s+Own Account//i; if($occupations[0] =~ /works? (on|for) (.+)/i) { - $occupations[0] = "$2 Worker"; + $occupations[0] = "$2 worker"; } elsif($occupations[0] =~ /^Cleaner\s+(.+)/i) { - $occupations[0] = "$1 Cleaner"; - } else { - $occupations[0] = ucfirst($occupations[0]); + $occupations[0] = "$1 cleaner"; } + $occupations[0] = ucfirst($occupations[0]); $occupations[0] =~ s/\s+heavy worker$//i; $occupations[0] =~ s/\s+own business$//i; } else { @@ -11346,6 +11362,26 @@ sub dump_places { } } +sub dump_occupations { + my $all_occupations = shift; + + return if(scalar(keys(%{$all_occupations})) == 0); + + foreach my $occupation(sort keys %{$all_occupations}) { + print "$occupation: "; + my $previous; + foreach my $person(@{$all_occupations->{$occupation}}) { + if($previous && ($person->xref() eq $previous->xref())) { + next; + } + print $person->as_string({ include_years => 1, middle_names => 1, nee => 1 }), + ';'; + $previous = $person; + } + print "\n"; + } +} + # Given a place return its latitude and longitude sub get_location($) {