From 004f6a7beac92dc8631d483c9015fb3e0340e047 Mon Sep 17 00:00:00 2001 From: "hieda_kyuko@hpr" <ugo58956@protonmail.com> Date: Thu, 22 May 2025 17:01:18 +0200 Subject: [PATCH] PoC: basic "search" feature --- lib/App/Dia.pm | 2 +- lib/App/MasterUtils.pm | 26 ++++++++++++++++++++++++++ lib/App/Navi.pm | 2 +- src/oud2_parser.pl | 12 ++++++++---- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/lib/App/Dia.pm b/lib/App/Dia.pm index 6da98cb..5c5be6e 100644 --- a/lib/App/Dia.pm +++ b/lib/App/Dia.pm @@ -76,7 +76,7 @@ sub format_syubetsu my %syubetsu; $syubetsu{'name'} = $_[0]; - $syubetsu{'ryaku'} = $_[1]; + # $syubetsu{'ryaku'} = $_[1]; return \%syubetsu; } diff --git a/lib/App/MasterUtils.pm b/lib/App/MasterUtils.pm index 48c1917..c74110b 100644 --- a/lib/App/MasterUtils.pm +++ b/lib/App/MasterUtils.pm @@ -72,6 +72,32 @@ sub sta_from_index return sta_from_id $master, @{ $rosen->{'eki'} }[$index]; } +sub search_eki +{ + # For now the query must be strictly equal to the target. + my ($master, $query) = @_; + my $all = $master->{'eki_index'}; + my @results; + + foreach my $index (keys %$all) + { + if ($all->{$index}->{'ekimei'} eq $query) + { + push @results, { index => $index, frame => $all->{$index} }; + } + } + + if (scalar @results == 0) + { + Log::i "No station matching the query $query was found."; + } + else + { + my $final = @results[0]; + return $final->{'index'}; + } +} + sub get_routes { my $master = $_[0]; diff --git a/lib/App/Navi.pm b/lib/App/Navi.pm index bf7c114..08489d9 100644 --- a/lib/App/Navi.pm +++ b/lib/App/Navi.pm @@ -125,7 +125,7 @@ sub Raptor_simple } } } - if (!$substituted && $visited{$p} < 2 * scalar @rosens) + if (!$substituted && $visited{$p} <= 2 * scalar @rosens) { push @Q, [$r, $d, $p]; } diff --git a/src/oud2_parser.pl b/src/oud2_parser.pl index 96dab04..c72ed24 100644 --- a/src/oud2_parser.pl +++ b/src/oud2_parser.pl @@ -100,13 +100,13 @@ SYUBETSU_STRUCT ::= SYUBETSU_BEGIN GARBAGE_LINES action => Dia::second SYUBETSU_SUB ::= SYUBETSU_NAME - SYUBETSU_RYAKU + # SYUBETSU_RYAKU action => Dia::format_syubetsu SYUBETSU_BEGIN ~ 'Ressyasyubetsu.' SYUBETSU_NAME ::= 'Syubetsumei=' NAME action => Dia::second -SYUBETSU_RYAKU ::= 'Ryakusyou=' NAME - action => Dia::second +#SYUBETSU_RYAKU ::= 'Ryakusyou=' NAME +# action => Dia::second DIA_BEGIN ::= 'Dia.' action => Dia::begin_dia_section @@ -343,4 +343,8 @@ foreach my $frame (values %{ $master{'rosen'} }) } # FrameUtils::hassya_hyou \%master, 'sekihoku1_28'; -Navi::Raptor_simple \%master, 'sibetu_9', 'sibetu_34', 800; + +my $d = MasterUtils::search_eki \%master, '幾寅'; +my $a = MasterUtils::search_eki \%master, '音別'; + +Navi::Raptor_simple \%master, $d, $a, 334; -- GitLab