summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scheibe <rene.scheibe@gmail.com>2014-09-12 14:33:19 +0200
committerRené Scheibe <rene.scheibe@gmail.com>2014-09-25 18:28:44 +0200
commit99c134096264bf2618f4e20a33cc3644a76e5feb (patch)
tree9087fa92bd56f8e73cc7cc604bc0d00f18845fc5
parentac20d58df72a1fb37da20e34a1b12339766ab071 (diff)
downloadninka-99c134096264bf2618f4e20a33cc3644a76e5feb.tar.gz
refactoring - using File::Basename to get the directory a script
-rwxr-xr-xextComments/extComments.pl13
-rwxr-xr-xfilter/filter.pl13
-rwxr-xr-xmatcher/matcher.pl13
-rwxr-xr-xninka.pl13
-rwxr-xr-xsenttok/senttok.pl13
-rwxr-xr-xsplitter/splitter.pl13
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;
diff --git a/ninka.pl b/ninka.pl
index f0db3f9..a2ee837 100755
--- a/ninka.pl
+++ b/ninka.pl
@@ -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 {
($_) = @_;