AI-MicroStructure
view release on metacpan or search on metacpan
if(!$conf{"drop"} && !$conf{"write"}and $ARGV[0] !~/structures/){
# find out the structure name
$structure = shift || $AI::MicroStructure::structure;
if (!length $conf{category} && $structure =~ m{^([^/]+)/(.*)}s) {
$structure = $1;
$conf{category} = $2;
}
AI::MicroStructure->new( $structure, category => "new" )
unless AI::MicroStructure->has_structure( $structure );
# my $module = "AI::MicroStructure::$structure";
my $module = "$absstructdir/$structure.pm";
bin/micro-wiki view on Meta::CPAN
my $url = $ARGV[0];
my @inx;
my @test;
my $search="";
my $TOP="wikipedia";
my $carry = {count=>0,max=>0};
sub nicefy { return reverse sort {length($a) <=> length($b)}@_ }
sub quantify {my $base = {}; map{$base->{$_} = $base->{$_}?$base->{$_}+1:1}@_; return $base; }#return reverse sort {length($a) <=> length($b)}@_ }
sub list_iter {
my @ar = @_;
my $pos = 0;
return sub {
return if $pos >= @ar;
my @r = ( $pos, $ar[$pos] ); # Note: returns ( index, value )
$pos++;
return @r;
t/canned/docs/wolfram/Runs.html view on Meta::CPAN
13.
134 entries
last updated.
sat feb 16 2013
created.
developed, and nurtured by eric weisstein at wolfram research
probability and statistics >
runs
kolakoski sequence
run
run-length encoding
s-cluster
s-run
wolfram web resources
mathematica »
the #1 tool for creating demonstrations and anything technical.
wolfram.
alpha »
explore anything with the first computational knowledge engine.
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" );
( $docs, $words ) = $cg->search('pony');
( $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 );
ok( !length $@, "able to load TDM file $@" );
is( $y->doc_count(), 177, "correct document count" );
is( $y->term_count(), 2036, "correct term count" );
($docs, $words) = $y->mixed_search( { terms => [ 111, 109, 23 ], docs => [33,21,12] });
is( scalar keys %$words,141, "Got right number of results");
is(sprintf("%2.2f", $docs->{163}), 1.09, "mixed search got right doc value");
is(sprintf("%2.2f", $words->{248}), 0.52, "mixed search got right term value");
( run in 0.863 second using v1.01-cache-2.11-cpan-65fba6d93b7 )