Alvis-NLPPlatform
view release on metacpan or search on metacpan
lib/Alvis/NLPPlatform/Convert.pm view on Meta::CPAN
package Alvis::NLPPlatform::Convert;
# The name
# of the directory if defined, in the proirity order, from the variable
# C<SPOOLDIR> in the section C<CONVERTERS>, C<SPOOLDIR> in the section
# C<alvis_connection>. If any name can be determine,
# if (defined $config->{"CONVERTERS"}->{"SPOOLDIR"}) {
# $ODIR = $config->{"CONVERTERS"}->{"SPOOLDIR"};
# } else {
# if (defined $config->{"alvis_connection"}->{"SPOOLDIR"}) {
# $ODIR = $config->{"alvis_connection"}->{"SPOOLDIR"};
# } else {
use strict;
use warnings;
use utf8;
no utf8;
use Alvis::NLPPlatform::Document;
use File::MMagic;
use File::Basename;
use File::Path qw(mkpath);
use File::Touch;
use Data::Dumper;
use Cwd;
our $VERSION=$Alvis::NLPPlatform::VERSION;
sub load_MagicNumber
{
my $config = shift;
my $mm = new File::MMagic; # use internal magic file
print STDERR "Loading complementary magic number ... ";
open FILEM, $config->{"CONVERTERS"}->{"SupplMagicFile"} or die "No such file or directory\n";
my $line;
while($line = <FILEM>) {
chomp $line;
$line =~ s/\s*\#.*//;
$line =~ s/^\s*//;
if ($line ne "") {
$mm->addMagicEntry($line);
}
}
print STDERR "done\n";
return($mm);
}
sub conversion_file_to_alvis_xml
{
# warn join("|", @_) . "\n";
my $file = shift;
my $AlvisConv = shift;
my $config = shift;
my $mm = shift;
my $outfile = $config->{ALVISTMP} . "/" . basename($file) . ".out";
my $infile = $file;
my $outfile_path;
my $outdata;
my $type = &get_type_file($infile, $mm);
if (($type !~ /xml/i) && ($type !~ /html/i)) {
print STDERR "Conversion of file ...\n";
# print Dumper $config;
if ((defined $config->{"CONVERTERS"}->{$type}) && ($config->{"CONVERTERS"}->{$type} ne "")) {
print STDERR "Converting to HTML ...\n" ;
my $commandline = $config->{"CONVERTERS"}->{$type} . " \"$infile\" > \"$outfile\"";
( run in 0.627 second using v1.01-cache-2.11-cpan-f56aa216473 )