AI-MicroStructure

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

  "Statistics::Descriptive" => 0,
  "Statistics::Distributions::Ancova" => 0,
  "Statistics::MVA::BayesianDiscrimination" => 0,
  "Statistics::MVA::HotellingTwoSample" => 0,
  "Storable" => 0,
  "Storable::CouchDB" => 0,
  "Sysadm::Install" => 0
);


unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
  delete $WriteMakefileArgs{TEST_REQUIRES};
  delete $WriteMakefileArgs{BUILD_REQUIRES};
  $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}

delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
  unless eval { ExtUtils::MakeMaker->VERSION(6.52) };

WriteMakefile(%WriteMakefileArgs);

bin/from-folder.pl  view on Meta::CPAN

our %opts = (cache_file =>
              sprintf("/tmp/%s.cache",
              $curSysDate));

GetOptions (\%opts, "cache_file=s");

our $cache = {};
our @target = split("\/",$opts{cache_file});
my $set = AI::MicroStructure::ObjectSet->new();

eval {
    local $^W = 0;  # because otherwhise doesn't pass errors
#`rm $opts{cache_file}`;
    $cache = lock_retrieve($opts{cache_file});

    $cache = {} unless $cache;

    warn "New cache!\n" unless defined $cache;
};


bin/micro  view on Meta::CPAN


if(!-f $module){
print "no\n\e[00;33m $module\e[00m";
print "create like\n\e[00;33mmicro $structure new verbose\e[00m";

exit;
}

# load the remote structure if needed
if ( $conf{remote} || $conf{check} || $conf{sources}) {
    eval "require '$module';";
    die "structure '$structure' is not updatable!\n"
        unless $module->has_remotelist();
}

# informative options
print STDERR
"meta, a simple front-end to AI::MicroStructure version $AI::MicroStructure::VERSION\n"
  if $conf{version};
print STDERR $main->help if $conf{help};

bin/micro-relation  view on Meta::CPAN

    try{
    $str = join( "\n", $result->related() );
    $str = decruft($str);
    $memd->set($arg,$str);
    };
  }
  return $str;
}

try{
print rel(eval qw{$_}, $lang)  for @ARGV;
};
#

1;
__DATA__

bin/micro-wiki  view on Meta::CPAN

          $doc->{book}= [@book] unless(!@book);
          $doc->{pdf}= [@pdf] unless(!@pdf);
          $doc->{audio}= [@audio] unless(!@audio);
          $doc->{related} = quantify $result->related();
          $doc->{links} = [sort grep{/http/}@all_links];
          
        


         
        #eval '$couchdb->store("$url" ,$doc)' or warn "error: $@\n";

      # createJsonFile($url,$doc);
    p $doc;

    return $doc;

}


}

bin/remote.pl  view on Meta::CPAN

}

sub has_remoteKnowledge { return defined $_[0]->source(); }

# main method: return the Knowledge from the remote source
sub remote_Knowledge {
    my $class = ref $_[0] || $_[0];
    return unless $class->has_remoteKnowledge();

    # check that we can access the network
    eval {
        require LWP::UserAgent;
        die "version 5.802 required ($LWP::VERSION installed)\n"
            if $LWP::VERSION < 5.802;
    };
    if ($@) {
        carp "LWP::UserAgent not available: $@";
        return;
    }

    # fetch the content

lib/AI/MicroStructure.pm  view on Meta::CPAN

our $str = "[A-Z]";
our $special = "any";
our $search;
our $data={};
our $item="";
our @items;
our @a=();
our ($init,$new,$drop,$available,$lib,
     $list,$use,$off,$switch,$mirror,
     $version,$help,$write,$verbose)  = (0,0,0,0,0,0,0,0,0,0,0,0,0,0);
eval "\$$_=1; " for @ARGV;
if( grep{/\bnew\b/} @ARGV ){ $new = 1; cleanArgs("new"); }
if( grep{/\bwrite\b/} @ARGV ){ $write = 1; cleanArgs("write");  };
if( grep{/\bdrop\b/} @ARGV ){ $drop = 1; cleanArgs("drop");  };
if( grep{/\bverbose\b/} @ARGV ){ $verbose = 1; cleanArgs("verbose");  };
our $StructureName = $ARGV[0]; # default structure
our $structure = $ARGV[0]; # default structure
our $state  = AI::MicroStructure::Util::config();
our @CWD=();
push @CWD ,  $state->{path}->{"cwd/structures"};
our $config = $state->{cfg};

lib/AI/MicroStructure.pm  view on Meta::CPAN

}

sub getComponents{
  my $x= {};
  $x->{"all_structures"} = [keys %MICRO];
  $x->{"count_struct"} = sprintf(keys %MICRO);
  $x->{"structures"} = {};

     foreach my $con (@{$x->{"all_structures"}}){
      next unless($con!~/any/);
      my @in = split("\n",eval{`cat $state->{path}->{"cwd/structures"}/$con.pm`;});

      $x->{"structures"}->{$state->{path}->{"cwd/structures"}}->{$con}->{name} =
        [grep{$_}grep {!/(our|my|use|sub|use|package|#|__|1)/}split("\n",`cat $state->{path}->{"cwd/structures"}/$con.pm`)];#,

      $x->{"structures"}->{$state->{path}->{"cwd/structures"}}->{$con}->{files}  =
       [split("\n",`ls -R  /home/santex/repos/KnowledgeInterDisciplinary/data/json | egrep -i "($con)";`)];
    }

 return $x;
}

lib/AI/MicroStructure.pm  view on Meta::CPAN

      ? ( 'foo', grep { !/^(?:foo|:all)$/ } keys %MICRO  ) # 'foo' is still first
      : @_;
    $Structure = $structures[0] if @structures;
    $micro = AI::MicroStructure->new( $Structure );
    # export the microname() function
    no strict 'refs';
    my $callpkg = caller;
    *{"$callpkg\::microname"} = \&microname;    # standard theme
    # load the classes in @structures
    for my $structure( @structures ) {
        eval "require AI::MicroStructure::$structure; import AI::MicroStructure::$structure;";
        croak $@ if $@;
        *{"$callpkg\::micro$structure"} = sub { $micro->name( $structure, @_ ) };
    }
}
sub new {
    my ( $class, @args ) = ( @_ );
    my $structure;
    $structure = shift @args if @args % 2;
    $structure = $Structure unless $structure; # same default everywhere
    # defer croaking until name() is actually called

lib/AI/MicroStructure.pm  view on Meta::CPAN

   if @badnames;
   my $code = << "EOC";
package AI::MicroStructure::$structure;
use strict;
use AI::MicroStructure::List;
our \@ISA = qw( AI::MicroStructure::List );
our \@List = qw( @{$structures{$structure}} );
__PACKAGE__->init();
1;
EOC
   eval $code;
   $MICRO{$structure} = 1; # loaded
   # export the microstructure() function
   no strict 'refs';
   my $callpkg = caller;
   *{"$callpkg\::micro$structure"} = sub { $micro->name( $structure, @_ ) };
   }
}
# load the content of __DATA__ into a structure
# this class method is used by the other AI::MicroStructure classes
sub load_data {

lib/AI/MicroStructure.pm  view on Meta::CPAN

          if $structure =~ /^(?:0|[1-9]\d*)$/;
    }
    else {
        ( $structure, $count ) = ( $self->{structure}, 1 );
    }
    if( ! exists $self->{micro}{$structure} ) {
        my ( $structure, $category ) = split /\//, $structure, 2;
        if( ! $MICRO{$structure}  ) {
            try{
#            `micro new $structure`;
            eval "require '$absstructdir/$structure.pm';";
            $MICRO{$structure} = 1; # loaded
            $self->{micro}{$structure}  = AI::MicroStructure->new($structure,category => $category);
            print $self->{micro}{$structure}->name( $count );
            return;
            }  catch{
            }
        }
    }
}
# corresponding method

lib/AI/MicroStructure.pm  view on Meta::CPAN

   if (@_) {
   ( $structure, $count ) = @_;
   ( $structure, $count ) = ( $self->{structure}, $structure )
   if defined($structure) && $structure =~ /^(?:0|[1-9]\d*)$/;
   }
   else {
   ( $structure, $count ) = ( $self->{structure}, 1 );
   }
   if( ! exists $self->{micro}{$structure} ) {
   if( ! $MICRO{$structure} ) {
   eval "require '$absstructdir/$structure.pm';";
   croak "MicroStructure list $structure does not exist!" if $@;
   $MICRO{$structure} = 1; # loaded
   }
   $self->{micro}{$structure} =
   "AI::MicroStructure::$structure"->new( %{ $self->{args} } );
   }
   $self->{micro}{$structure}->name( $count );
}
# corresponding method
sub namex {

lib/AI/MicroStructure.pm  view on Meta::CPAN

   ( $structure, $count ) = @_;
   ( $structure, $count ) = ( $self->{structure}, $structure )
   if defined($structure) && $structure =~ /^(?:0|[1-9]\d*)$/;
   }
   else {
   ( $structure, $count ) = ( $self->{structure}, 1 );
   }
   if( ! exists $self->{micro}{$structure} ) {
   if( ! $MICRO{$structure} ) {
    try {
   eval "require '$absstructdir/$structure.pm';";
   $MICRO{$structure} = 1; # loaded
   croak "MicroStructure list $structure does not exist!" if $@;
    }catch{
      }
   }
   $self->{micro}{$structure} =
   "AI::MicroStructure::$structure"->new( %{ $self->{args} } );
   }
   $self->{micro}{$structure}->name( $count );
}

lib/AI/MicroStructure.pm  view on Meta::CPAN

   $string =~ s/^\s//;
   return $string;
}
sub getBundle {
   my $self = shift;
my @structures = grep { !/^(?:any)/ } AI::MicroStructure->structures;
my @micros;
my @search=[];
for my $structure (@structures) {
   no strict 'refs';
   eval "require '$absstructdir/$structure.pm';";
   my %isa = map { $_ => 1 } @{"AI::MicroStructure::$structure\::ISA"};
   if( exists $isa{'AI::MicroStructure::Locale'} ) {
   for my $lang ( "AI::MicroStructure::$structure"->languages() ) {
   push @micros,
   ["AI::MicroStructure::$structure"->new( lang => $lang ),$lang];
   }
   }
   elsif( exists $isa{'AI::MicroStructure::MultiList'} ) {
   for my $cat ( "AI::MicroStructure::$structure"->categories(), ':all' ) {
   push @micros,

lib/AI/MicroStructure/Alias.pm  view on Meta::CPAN

use strict;
use warnings;
use Carp;

our $VERSION = '0.20';

sub init {
    my ( $self, $alias ) = @_;
    my $class = caller(0);

    eval "require AI::MicroStructure::$alias;";
    croak "Aliased structure AI::MicroStructure::$alias failed to load: $@"
        if $@;

    no strict 'refs';
    no warnings;

    # copy almost everything over from the original
    for my $k ( grep { ! /^(?:Theme|meta|import)$/ }
        keys %{"AI::MicroStructure::$alias\::"} )
    {

lib/AI/MicroStructure/Locale.pm  view on Meta::CPAN

    no strict 'refs';
    my $self = bless { @_, cache => [] }, $class;

    # compute some defaults
    if( ! exists $self->{category} ) {
        $self->{category} =
            exists $self->{lang}
            ? $self->{lang}
            : $ENV{LANGUAGE} || $ENV{LANG} || '';
        if( !$self->{category} && $^O eq 'MSWin32' ) {
            eval { require Win32::Locale; };
            $self->{category} = Win32::Locale::get_language() unless $@;
        }
    }

    my $cat = $self->{category};

    # support for territories
    if ( $cat && $cat ne ':all' ) {
        ($cat) = $cat =~ /^([-A-Za-z_]+)/;
        $cat = lc( $cat || '' );

lib/AI/MicroStructure/RemoteList.pm  view on Meta::CPAN

}

sub has_remotelist { return defined $_[0]->source(); }

# main method: return the list from the remote source
sub remote_list {
    my $class = ref $_[0] || $_[0];
    return unless $class->has_remotelist();

    # check that we can access the network
    eval {
        require LWP::UserAgent;
        die "version 5.802 required ($LWP::VERSION installed)\n"
            if $LWP::VERSION < 5.802;
    };
    if ($@) {
        carp "LWP::UserAgent not available: $@";
        return;
    }

    # figure out the default category (for an instance)

lib/AI/MicroStructure/RemoteList.pm  view on Meta::CPAN

    $str =~ s/$utf_re/$utf2asc{$1}/go;
    return $str;
}

1;

__END__

=head1 NAME

AI::MicroStructure::RemoteList - Retrieval of a remote source for a structure

=head1 SYNOPSIS

    package AI::MicroStructure::contributors;
    use strict;
    use AI::MicroStructure::List;
    our @ISA = qw( AI::MicroStructure::List );

    # data regarding the remote source
    our %Remote = (

t/canned/docs/number.pm  view on Meta::CPAN

figure
innumerableness
magnitude
majority
minority
multiplicity
number
numerosity
numerousness
preponderance
prevalence
property
roundness
total

t/canned/docs/numbers.pm  view on Meta::CPAN

majority
minority
multiplicity
music
number
numbers
numerosity
numerousness
piece_of_writing
preponderance
prevalence
property
roundness
section
subdivision
total
writing
written_communication
written_language
written_material

t/t/0010.t  view on Meta::CPAN

our %opts = (cache_file =>
              sprintf("%s/%s/%s_.cache",
              $PWD,"canned",$curSysDate));

GetOptions (\%opts, "cache_file=s");

our $cache = {};
our @target = split("\/",$opts{cache_file});
ok(my $set = AI::MicroStructure::ObjectSet->new());

eval {
    local $^W = 0;  # because otherwhise doesn't pass errors
#`rm $opts{cache_file}`;
    $cache = lock_retrieve($opts{cache_file});

    $cache = {} unless $cache;

    warn "New cache!\n" unless defined $cache;
};


t/t/0011.t  view on Meta::CPAN

our %opts = (cache_file =>
              sprintf("%s/%s/%s_.cache",
              $PWD,"t/canned",$curSysDate));

GetOptions (\%opts, "cache_file=s");

our $cache = {};
our @target = split("\/",$opts{cache_file});
ok(my $set = AI::MicroStructure::ObjectSet->new());

eval {
    local $^W = 0;  # because otherwhise doesn't pass errors
#`rm $opts{cache_file}`;
    $cache = lock_retrieve($opts{cache_file});

    $cache = {} unless $cache;

    warn "New cache!\n" unless defined $cache;
};


t/t/0011.t  view on Meta::CPAN

our %opts = (cache_file =>
              sprintf("/tmp/%s.cache",
              $curSysDate));

GetOptions (\%opts, "cache_file=s");

our $cache = {};
our @target = split("\/",$opts{cache_file});
my $set = AI::MicroStructure::ObjectSet->new();

eval {
    local $^W = 0;  # because otherwhise doesn't pass errors
#`rm $opts{cache_file}`;
    $cache = lock_retrieve($opts{cache_file});

    $cache = {} unless $cache;

    warn "New cache!\n" unless defined $cache;
};


t/t/002.t  view on Meta::CPAN

use AI::MicroStructure;

plan tests => 2;

NEW_OK: {
    my $meta = AI::MicroStructure->new('foo');
    isa_ok( $meta, 'AI::MicroStructure' );
}

NEW_UNKNOWN: {
    my $meta = eval { AI::MicroStructure->new('bam') };
    isa_ok( $meta, 'AI::MicroStructure' );
}

1;

t/t/006.t  view on Meta::CPAN


  ( $docs, $words ) = $cg->search('snake');
  is(sprintf("%2.2f", $docs->{"Third Document"}), 35.35, "repeating search does not change results" );

  ( $docs, $words ) = $cg->search('pony');

  #Test search starting at singleton node
  #is(sprintf("%2.2f", $docs->{"Second Document"}), '50.00', "search starting at singleton");

  # Try adding a duplicate title
  eval{ $cg->add_documents( %docs ); };
  ok(  $@ =~ /^Tried to add document with duplicate identifier:/,
     "complained about duplicate title");

  my %new_docs = (
    'Fourth Document' => { 'elephant' => 1, 'fox' => 2, 'boa' => 1 },
    'Fifth Document' => { 'bull' => 1, 'eagle' => 1 }
    );

  eval{ $cg->add_documents( %new_docs ) };
  ok( !length $@, "able to add more documents" );
  is ( $cg->doc_count(), 5, "document count is correct" );


  # Check that the word count is right
  my @words = $cg->term_list();
  is ( scalar @words, 9, "word count is correct" );
  my $flat = join '', sort @words;
  is ( $flat, 'boabullcamelconstrictoreagleelephantfoxponysnake', "word list is correct" );

t/t/006.t  view on Meta::CPAN

  is(sprintf("%2.2f", $docs->{"First Document"}), 28.36, 'result changed for non-singleton search');

  ( $docs, $words ) = $cg->find_similar('First Document');
  is(sprintf("%2.2f", $docs->{"First Document"}), 122.34, 'find similar search correct');
  is(sprintf("%2.2f", $docs->{"Fourth Document"}), 5.57, 'find similar search correct');


  # Try storing the sucker
  if ( !$XS ) {
    my $path = "Search::ContextGraph::Test::Stored";
    eval { $cg->store( $path ) };
    ok( !length $@, "able to store object to file" );

    my $x = Search::ContextGraph->retrieve( $path );
    ok( UNIVERSAL::isa( $x, 'Search::ContextGraph'), "reload object from stored file" );

    #cleanup
    eval { unlink $path; };
    ok( !length $@, "remove stored file" );


    ($docs, $words ) = $cg->find_similar('First Document');
    is(sprintf("%2.2f", $docs->{"First Document"}), 122.34, 'reloaded search object works fine');
  }

  my $y = Search::ContextGraph->new( debug => 1, xs => $XS );
  $path = sprintf("$PWD/t/canned/sample.tdm");
  $y->load_from_tdm( $path );



( run in 1.783 second using v1.01-cache-2.11-cpan-98e64b0badf )