diff options
author | René Scheibe <rene.scheibe@gmail.com> | 2014-09-12 14:33:19 +0200 |
---|---|---|
committer | René Scheibe <rene.scheibe@gmail.com> | 2014-09-25 18:28:44 +0200 |
commit | 99c134096264bf2618f4e20a33cc3644a76e5feb (patch) | |
tree | 9087fa92bd56f8e73cc7cc604bc0d00f18845fc5 | |
parent | ac20d58df72a1fb37da20e34a1b12339766ab071 (diff) | |
download | ninka-99c134096264bf2618f4e20a33cc3644a76e5feb.tar.gz |
refactoring - using File::Basename to get the directory a script
-rwxr-xr-x | extComments/extComments.pl | 13 | ||||
-rwxr-xr-x | filter/filter.pl | 13 | ||||
-rwxr-xr-x | matcher/matcher.pl | 13 | ||||
-rwxr-xr-x | ninka.pl | 13 | ||||
-rwxr-xr-x | senttok/senttok.pl | 13 | ||||
-rwxr-xr-x | splitter/splitter.pl | 13 |
6 files changed, 12 insertions, 66 deletions
diff --git a/extComments/extComments.pl b/extComments/extComments.pl index 7c7448f..8996024 100755 --- a/extComments/extComments.pl +++ b/extComments/extComments.pl @@ -25,13 +25,14 @@ use strict; use warnings; +use File::Basename qw(dirname); use Getopt::Std; my %opts = parse_cmdline_parameters(); my $verbose = exists $opts{v}; -my $path = get_my_path($0); +my $path = dirname($0); my $input_file = $ARGV[0]; my $comments_file = "$input_file.comments"; @@ -58,16 +59,6 @@ Options: return %opts; } -sub get_my_path { - my ($self) = @_; - my $path = $self; - $path =~ s/\/+[^\/]+$//; - if ($path eq '') { - $path = './'; - } - return $path; -} - sub determine_comments_cmd { my ($input_file, $comments_file) = @_; diff --git a/filter/filter.pl b/filter/filter.pl index 6533c5d..b3d3a55 100755 --- a/filter/filter.pl +++ b/filter/filter.pl @@ -25,13 +25,14 @@ use strict; use warnings; +use File::Basename qw(dirname); use Getopt::Std; my $INPUT_FILE_EXTENSION = 'sentences'; parse_cmdline_parameters(); -my $path = get_my_path($0); +my $path = dirname($0); my $input_file = $ARGV[0]; my $file_critical_words = "$path/criticalword.dict"; @@ -68,16 +69,6 @@ sub parse_cmdline_parameters { } } -sub get_my_path { - my ($self) = @_; - my $path = $self; - $path =~ s/\/+[^\/]+$//; - if ($path eq '') { - $path = './'; - } - return $path; -} - sub read_critical_words { my ($file) = @_; my @critical_words = (); diff --git a/matcher/matcher.pl b/matcher/matcher.pl index 2384063..499bd96 100755 --- a/matcher/matcher.pl +++ b/matcher/matcher.pl @@ -25,6 +25,7 @@ use strict; #use warnings; +use File::Basename qw(dirname); use Getopt::Std; my %NON_CRITICAL_RULES = (); @@ -111,7 +112,7 @@ my %opts = parse_cmdline_parameters(); my $verbose = exists $opts{v}; -my $path = get_my_path($0); +my $path = dirname($0); my $input_file = $ARGV[0]; my $rules_file = "$path/rules.dict"; @@ -178,16 +179,6 @@ Options: return %opts; } -sub get_my_path { - my ($self) = @_; - my $path = $self; - $path =~ s/\/+[^\/]+$//; - if ($path eq '') { - $path = './'; - } - return $path; -} - sub is_unknown { my ($s) = @_; my @f = split /,/, $s; @@ -18,6 +18,7 @@ use strict; use warnings; +use File::Basename qw(dirname); use Getopt::Std; my %opts = parse_cmdline_parameters(); @@ -26,7 +27,7 @@ my $verbose = exists $opts{v}; my $delete = exists $opts{d}; my $force = exists $opts{f}; -my $path = get_my_path($0); +my $path = dirname($0); my $input_file = $ARGV[0]; @@ -109,16 +110,6 @@ Options: return %opts; } -sub get_my_path { - my ($self) = @_; - my $path = $self; - $path =~ s/\/+[^\/]+$//; - if ($path eq '') { - $path = './'; - } - return $path; -} - sub forward_verbosity { return $verbose ? '-v ' : ''; } diff --git a/senttok/senttok.pl b/senttok/senttok.pl index 780740d..2416123 100755 --- a/senttok/senttok.pl +++ b/senttok/senttok.pl @@ -25,6 +25,7 @@ use strict; #use warnings; +use File::Basename qw(dirname); use Getopt::Std; my $TOO_LONG = 70; @@ -32,7 +33,7 @@ my $INPUT_FILE_EXTENSION = 'goodsent'; parse_cmdline_parameters(); -my $path = get_my_path($0); +my $path = dirname($0); my $input_file = $ARGV[0]; my $license_sentences_file = "$path/licensesentence.dict"; @@ -142,16 +143,6 @@ sub parse_cmdline_parameters { } } -sub get_my_path { - my ($self) = @_; - my $path = $self; - $path =~ s/\/+[^\/]+$//; - if ($path eq '') { - $path = './'; - } - return $path; -} - sub normalize_gpl { my ($line) = @_; my $later = 0; diff --git a/splitter/splitter.pl b/splitter/splitter.pl index b757c7b..4e96402 100755 --- a/splitter/splitter.pl +++ b/splitter/splitter.pl @@ -38,13 +38,14 @@ use strict; use warnings; +use File::Basename qw(dirname); use Getopt::Std; my $INPUT_FILE_EXTENSION = 'comments'; parse_cmdline_parameters(); -my $path = get_my_path($0); +my $path = dirname($0); my $input_file = $ARGV[0]; my $abbreviations_file = "$path/splitter.abv"; @@ -148,16 +149,6 @@ sub parse_cmdline_parameters { } } -sub get_my_path { - my ($self) = @_; - my $path = $self; - $path =~ s/\/+[^\/]+$//; - if ($path eq '') { - $path = './'; - } - return $path; -} - sub clean_sentence { ($_) = @_; |