PS C:\Users\dtrzcinski\workspace\Clear Pre Processing> scandeps -c '.\XML Classifier JDE.pl'
# Use of runtime loader module Module::Implementation detected. Results of static scanning may be incomplete.
# Use of runtime loader module Module::Runtime detected. Results of static scanning may be incomplete.
(set by Moose): No such file or directory at C:/perl/site/lib/Module/ScanDeps/DataFeed.pm line 26.
CHECK failed--call queue aborted.
SYSTEM ERROR in compiling .\XML Classifier JDE.pl: 512 at C:/perl/site/lib/Module/ScanDeps.pm line 1348.
####
PS C:\Users\dtrzcinski\workspace\Clear Pre Processing> perl -V
Summary of my perl5 (revision 5 version 20 subversion 1) configuration:
Platform:
osname=MSWin32, osvers=6.1, archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
useithreads=define, usemultiplicity=define
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DPE
RL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T',
optimize='-O1 -MD -Zi -DNDEBUG',
cppflags='-DWIN32'
ccversion='18.00.31101', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -libpath:"c:\perl\lib\CORE" -machine:x86'
libpth=\lib
libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib ol
eaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.
lib
perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.li
b oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msv
crt.lib
libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl520.lib
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -libpath:"c:\perl\lib\CORE" -machine:x86
'
Characteristics of this binary (from libperl):
Compile-time options: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY
PERLIO_LAYERS PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP PERL_NEW_COPY_ON_WRITE
PERL_PRESERVE_IVUV USE_ITHREADS USE_LARGE_FILES
USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
Built under MSWin32
Compiled at Jan 14 2015 14:56:04
@INC:
C:/perl/site/lib/MSWin32-x86-multi-thread
C:/perl/site/lib
C:/perl/lib
.
####
#!/usr/bin/perl
use Modern::Perl;
no warnings;
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
# do singleton check and possible bailout as early as possible.
use Fcntl qw(:flock);
my $lockfile = 'E:\\FlowData\\PreProcess\\classifier.lock';
sub BailOut {
print "$0 is already running. Exiting.\n";
exit(1);
}
open( my $fhpid, '>>', $lockfile ) or die "error: open '$lockfile': $!";
flock( $fhpid, LOCK_EX | LOCK_NB ) or BailOut();
use strict;
no warnings;
use AI::Categorizer;
use AI::Categorizer::Collection::Files;
use Algorithm::NaiveBayes::Model::Frequency;
use File::Spec;
use File::Copy;
use File::ChangeNotify;
our $cat_file = 'E:\\FlowData\\PreProcess\\cats.txt';
our $path = 'E:\\FlowData\\ALL';
my $watcher = File::ChangeNotify->instantiate_watcher(
directories => [$path],
filter => qr/\.(?:xml)$/,
);
use AI::Categorizer::Learner::NaiveBayes;
our %files;
our $nb = AI::Categorizer::Learner::NaiveBayes->restore_state('E:\\FlowData\\PreProcess\\state');
print "Begining to watch $path for changes.\n";
while ( my @events = $watcher->wait_for_events() ) {
print "New files have been detected.\n";
open my $out_fh, '>', $cat_file;
opendir( DIR, $path ) or die $!;
while ( my $file = readdir(DIR) ) {
# Use a regular expression to ignore files beginning with a period
next if ( $file =~ m/^\./ );
print {$out_fh} "$file \n";
}
closedir(DIR);
close $out_fh;
my $c = new AI::Categorizer::Collection::Files( path => $path, category_file => $cat_file );
while ( my $document = $c->next ) {
my $hypothesis = $nb->categorize($document);
print "Classified ", $hypothesis->document_name();
print " as ", $hypothesis->best_category, "\n";
my $original = $path . "\\" . $hypothesis->document_name();
my $classified = 'E:\\FlowData\\PreProcess\\'.$hypothesis->best_category().'\\'.$hypothesis->document_na
me();
if ( $original =~ /^(.*)$/ ) {
$original = $1; # $data now untainted
} else {
die "Bad data in $original"; # log this somewhere
}
if ( $classified =~ /^(.*)$/ ) {
$classified = $1; # $data now untainted
} else {
die "Bad data in $classified"; # log this somewhere
}
move( $original, $classified );
}
}