summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordmg <dmg@uvic.ca>2014-08-02 00:49:15 -0700
committerDaniel M German <dmg@uvic.ca>2015-01-10 02:24:27 -0800
commite4882adf2adf0e8e899a4efda5f48a26ed982dcf (patch)
treeb5891ab522d24c91209e0de2dbdd007f630387f6
parent3493612d6b453df4fe7154843ee877f5812a5d2c (diff)
downloadninka-e4882adf2adf0e8e899a4efda5f48a26ed982dcf.tar.gz
updated the excel extractor to skip binary files, added license and author
-rw-r--r--ninka-excel.pl102
1 files changed, 47 insertions, 55 deletions
diff --git a/ninka-excel.pl b/ninka-excel.pl
index bfa59c6..c06c830 100644
--- a/ninka-excel.pl
+++ b/ninka-excel.pl
@@ -1,4 +1,20 @@
#!/usr/bin/perl
+#
+# Copyright (C) 2014 Anthony Kohan and Daniel M. German
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
use strict;
use Switch;
@@ -65,76 +81,52 @@ find(
print "***** Beginning Execution of Ninka *****\n";
foreach my $file (@files) {
- print "Running ninka on file [$file]\n";
- execute("perl ${path}/ninka.pl '$file'");
+ if (-T $file) {
+ print "Running ninka on file [$file]\n";
+ execute("perl ${path}/ninka.pl '$file'");
+ }
}
-my @ninkafiles;
-find(
- sub {
- my $ext = getExtension($File::Find::name);
- if($ext =~ m/(comments|sentences|goodsent|badsent|senttok|license)$/){
- push @ninkafiles, $File::Find::name;
- }
- },
- $dirname
-);
print "***** Entering Ninka Data into excell file [$excelFile] *****\n";
my $row = 1;
-foreach my $file (@ninkafiles) {
+foreach my $file (@files) {
my $filepath = dirname($file);
$filepath =~ s/$dirname//;
- my $basefile = basename($file);
- my $rootfile = removeExtension($basefile);
+ my $basefile = fileparse($file, ());
my $packname = basename($pack);
#Read entire file into a string
- open (my $fh, '<', $file) or die "Can't open file $!";
- my $filedata = do { local $/; <$fh> };
+ my $filename = "${file}.license";
- my $sth;
- switch (getExtension($basefile)){
- case ".comments" {
- ;
- }
- case ".sentences" {
- ;
- }
- case ".goodsent" {
- ;
- }
- case ".badsent" {
- ;
- }
- case ".senttok" {
- ;
- }
- case ".license" {
- print "Inserting [$basefile] into table licenses\n";
- my @columns = parseLicenseData($filedata);
-
- $worksheet->write($row, 0, $packname);
- $worksheet->write($row, 1, $filepath);
- $worksheet->write($row, 2, $rootfile);
-
- my $originalFile = $file;
- $originalFile =~ s/\.license$//;
-
- if (-T $originalFile) {
- foreach my $i (0..7) {
- $worksheet->write($row, $i+3, $columns[$i]);
- }
- } else {
- $worksheet->write($row, 3, "Binary File");
- }
-
- $row++;
+ $worksheet->write($row, 0, $packname);
+ $worksheet->write($row, 1, $filepath);
+ $worksheet->write($row, 2, $basefile);
+
+ print "Inserting [$basefile] into table spreedsheet\n";
+
+ if (-T $filename) {
+
+ open (my $fh, '<', $filename) or die "Can't open file $!";
+ my $filedata = do { local $/; <$fh> };
+
+ my @columns = parseLicenseData($filedata);
+
+
+ my $originalFile = $file;
+ $originalFile =~ s/\.license$//;
+
+ foreach my $i (0..7) {
+ $worksheet->write($row, $i+3, $columns[$i]);
}
+ close($fh);
+
+ } else {
+ $worksheet->write($row, 3, "Binary File");
}
- close($fh);
+ $row++;
}
$workbook->close();