AI-MicroStructure
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
$ micro ufo all; # all words of the ufo structure
$ micro ufo 5; # 5 random words of the ufo structure
$ micro any 10; # 10 random words of any structure you have created
$ micro --init # initializes active memory
$ micro --export # export relations from couchdb into git repo and tag data
# oneliners i like to use
$ for i in `micro structures`; do echo $i; done; # echos all the structures
$ for i in `micro ufo all`; do echo $i; done; # echos all words in ufo
$ for i in `micro structures`; do micro all $i; done; # echos all stuctures all words
bin/from-folder.pl view on Meta::CPAN
}
find(\&translate, "$TOP");
p @{[keys %$files,reverse @ARGV,$storage]};
__DATA__
our $c = AI::MicroStructure::Context->new(@ARGV);
$c->retrieveIndex($PWD."/t/docs"); #"/home/santex/data-hub/data-hub" structures=0 text=1 json=1
my $style = {};
$style->{explicit} = 1;
ok($c->simpleMixedSearch($style,$_)) && ok($c->play($style,$_)) for
qw(atom antimatter planet);
nogo="http:\/\/|Articles|Artikel|Wikipedia|Commons|Tracking_|Hidden_|Talk_|_talk|Use_dmy_dates|_Diskussion|Pages_containing "
function getcat(){
search=$(perl -e "print ucfirst('$1')");
q="http://$MICRO_LANG.wikipedia.org/wiki/$search";
for i in `mojo get "$q" a attr href | egrep "^\/wiki\/(Category|Kategorie)" | egrep -vi "("$nogo")" | sort | sed -s "s/\/wiki\///"`; do q=$i; echo $i | urldecode; done
}
getcat $search
#qq=$(echo "$search" | sed "s/^.*.://" | tr "_" "|");
#q=$1; cat=$(for i in `getcat "$q"`; do getcat "$i"; done); echo "$cat" | data-freq | egrep -v "http" | sed -s "s/^.*.: //" | egrep -i "($qq)"
#q=$1; cat=$(for i in `getcat "$q"`; do qq=$(echo "$q" | sed -s "s/^.*.\://"); getcat "$i"; done); echo "$cat" | egrep -vi "http:" | data-freq | sort -n
#echo -e "\n"
bin/getnice view on Meta::CPAN
if [ ! $q ]
then
q="ufo"
fi
if [ ! $dir ]
then
dir="/home/santex/data-hub/stock/KnowledgeInterDisciplinary/"
fi
j=$(for i in `egrep -rli "$q" | grep List_of_`; do
echo $i;
#echo $i | xargs -0 json-printer \-f | egrep "^\".*.$" | egrep -v ":|http|wiki|index|\/|Externallinks|References|Seealso|Listof|#|[1-9][0-9][0-9][0-9]" | tr -d "\",";
done);
echo "$j"| egrep -i "^$q|_$q"
bin/localfiles view on Meta::CPAN
#!/usr/bin/env perl
use File::Find::Rule;
use strict;
use warnings;
use JSON;
use Cache::Memcached::Fast;
use AI::MicroStructure;
use Data::Dumper;
my $data={};
our $memd = new Cache::Memcached::Fast({
servers => [ { address => 'localhost:11211', weight => 2.5 }],
namespace => 'my:',
connect_timeout => 0.2,
io_timeout => 0.1,
close_on_error => 1,
compress_threshold => 100_000,
compress_ratio => 0.9,
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};
print map "$_\n", AI::MicroStructure->structures if $conf{structures};
bin/micro-sense view on Meta::CPAN
#!/usr/bin/perl -X
use strict;
use AnyDBM_File;
use Fcntl;
use Data::Dumper;
use JSON;
use AI::MicroStructure::WordBlacklist;
my @set;
my $data = {};
my %structure;
my $fresh=1;
my $wn;
my $debug = 0;
my $words = 1;
my $count = 0;
if( grep{/\bdebug\b/} @ARGV ){$debug = 1; cleanArgs("debug"); };
if( grep{/\bwords\b/} @ARGV ){$words = 1; cleanArgs("words"); };
lib/AI/MicroStructure.pm view on Meta::CPAN
our $VERSION = '0.20';
our $Structure = 'any'; # default structure
our $CODESET = 'utf8';
our $LANG = '';
our %MICRO;
our %MODS;
our %ALIEN;
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"); };
lib/AI/MicroStructure/List.pm view on Meta::CPAN
use strict;
use AI::MicroStructure (); # do not export metaname and friends
use AI::MicroStructure::RemoteList;
use List::Util qw( shuffle );
use Carp;
our @ISA = qw( AI::MicroStructure::RemoteList );
our $VERSION = '0.20';
sub init {
my ($self, $data) = @_;
my $class = caller(0);
$data ||= AI::MicroStructure->load_data($class);
croak "The optional argument to init() must be a hash reference"
if ref $data ne 'HASH';
no strict 'refs';
no warnings;
${"$class\::Theme"} = ( split /::/, $class )[-1];
@{"$class\::List"} = do { my %seen;
grep !$seen{$_}++, split /\s+/, $data->{names} };
*{"$class\::import"} = sub {
my $callpkg = caller(0);
my $structure = ${"$class\::Theme"};
my $meta = $class->new();
*{"$callpkg\::meta$structure"} = sub { $meta->name(@_) };
};
${"$class\::meta"} = $class->new();
}
sub name {
lib/AI/MicroStructure/MultiList.pm view on Meta::CPAN
use strict;
use AI::MicroStructure (); # do not export metaname and friends
use AI::MicroStructure::RemoteList;
use List::Util qw( shuffle );
use Carp;
our @ISA = qw( AI::MicroStructure::RemoteList );
our $VERSION = '0.20';
sub init {
my ($self, $data) = @_;
my $class = caller(0);
$data ||= AI::MicroStructure->load_data($class);
no strict 'refs';
# note: variables mentioned twice to avoid a warning
my $sep = ${"$class\::Separator"} = ${"$class\::Separator"} ||= '/';
my $tail = qr/$sep?[^$sep]*$/;
# compute all categories
my @categories = ( [ $data->{names}, '' ] );
while ( my ( $h, $k ) = @{ shift @categories or []} ) {
if ( ref $h eq 'HASH' ) {
push @categories,
map { [ $h->{$_}, ( $k ? "$k$sep$_" : $_ ) ] } keys %$h;
}
else { # leaf
my @items = split /\s+/, $h;
while ($k) {
push @{ ${"$class\::MultiList"}{$k} }, @items;
$k =~ s!$tail!!;
}
}
}
${"$class\::Default"} = ${"$class\::Default"} = $data->{default} || ':all';
${"$class\::Theme"} = ${"$class\::Theme"} = ( split /::/, $class )[-1];
*{"$class\::import"} = sub {
my $callpkg = caller(0);
my $structure = ${"$class\::Theme"};
my $meta = $class->new;
*{"$callpkg\::meta$structure"} = sub { $meta->name(@_) };
};
${"$class\::meta"} = ${"$class\::meta"} = $class->new();
lib/AI/MicroStructure/RemoteList.pm view on Meta::CPAN
)
: ( GET => $src )
);
my $res = $ua->request( $request );
if ( ! $res->is_success() ) {
carp "Failed to get content at $src (" . $res->status_line();
return;
}
# extract, cleanup and return the data
# if decoding the content fails, we just deal with the raw content
push @items =>
$class->extract( $res->decoded_content() || $res->content(),
$category || () );
}
# return unique items
my %seen;
return grep { !$seen{$_}++ } @items;
lib/AI/MicroStructure/Util.pm view on Meta::CPAN
package AI::MicroStructure::Util;
use strict;
use Cwd;
use Config::Auto;
use Env qw/PWD/;
sub get_cwd {
my @CWD; if (!-e ".micro") {
push @CWD, $ENV{HOME}."/data-hub";
} else {
push @CWD, getcwd();
}
return @CWD;
}
sub load_config {
my @CWD = AI::MicroStructure::Util::get_cwd();
my $config = {};#Config::Auto::parse(".micro", path => @CWD) || {};
lib/AI/MicroStructure/germany.pm view on Meta::CPAN
# names Herzebrock-Clarholz 33442
# names Langenberg 33449
# names Bielefeld 33602 33604 33605 33607 33609 33611 33613 33615 33617 33619 33647 33649 33659 33689 33699 33719 33729 33739
# names Versmold 33775
# names Oerlinghausen 33813
# names Werther 33824 99735
# names Borgholzhausen 33829
# names Kassel 34117 34119 34121 34123 34125 34127 34128 34130 34131 34132 34134
# names Melsungen 34212
# names Baunatal 34225
# names Fuldatal 34233
# names Vellmar 34246
# names Lohfelden 34253
# names Kaufungen 34260
# names Niestetal 34266
# names Schauenburg 34270
# names Gudensberg 34281
# names Spangenberg 34286
# names Zierenberg 34289
# names Ahnatal 34292
# names Helsa 34298
}
our $files={};
my $style = {};
$style->{explicit} = 1;
our $c = AI::MicroStructure::Context->new(@ARGV);
$c->retrieveIndex($TOP);#"data-hub" structures=0 text=1 json=1
my $cg = $c->{graph}->{content};
my @ranked_docs = $cg->simple_search( 'peanuts' );
# get back both related terms and docs for more power
my ( $docs, $words ) = $cg->search('dna');
p $docs;
p $words;
$files->{text}->{$name}=$rel_name;
}
}
p $files;
__DATA__
our $c = AI::MicroStructure::Context->new(@ARGV);
$c->retrieveIndex($PWD."/t/docs"); #"/home/santex/data-hub/data-hub" structures=0 text=1 json=1
my $style = {};
$style->{explicit} = 1;
ok($c->simpleMixedSearch($style,$_)) && ok($c->play($style,$_)) for
qw(atom antimatter planet);
#####################################################################
SKIP: {
skip "Renaming tmp files not supported on Win32", 1 if $^O eq "MSWin32";
blurt_atomic("one\ntwo\nthree", $TMP_FILE);
ok(-f $TMP_FILE, "$TMP_FILE exists");
}
#####################################################################
# Slurp
#####################################################################
my $data = slurp($TMP_FILE);
is($data, "one\ntwo\nthree", "$TMP_FILE contains right data");
#####################################################################
# Slurp from @ARGS
#####################################################################
@ARGV = ($TMP_FILE);
$data = slurp();
is($data, "one\ntwo\nthree", "$TMP_FILE contains right data");
#####################################################################
# pie
#####################################################################
pie( sub { s/three/four/g; $_; }, $TMP_FILE );
$data = slurp($TMP_FILE);
is($data, "one\ntwo\nfour", "$TMP_FILE got pied");
use Test::More tests =>8;
BEGIN {
use_ok('LWP');
use_ok('Storable::CouchDB');
my $s = Storable::CouchDB->new;
ok("sprintf $s->retrieve('doc')"); #undef if not exists
ok("sprintf $s->store('doc1' => 'data');");
ok('sprintf $s->store("doc2" => {"my" => "data"});');
ok('sprintf $s->store("doc3" => ["my", "data"]);');
ok("sprintf $s->store('doc4' => undef);");
ok("sprintf $s->delete('doc');");
my $browser = LWP::UserAgent->new();
my $seite = "http://127.0.0.1:5984";
# $seite = $browser->get($seite);
# ok($seite->is_success,"couch is there");
package AI::MicroStructure::test;
use strict;
use Test::More;
use AI::MicroStructure;
plan tests => 2;
$_ = 'canari';
my $data = AI::MicroStructure->load_data('AI::MicroStructure::test');
is( $_, 'canari', "load_data does not stomp the canari" );
is_deeply(
$data,
{ foo => "bar",
names => {
en => "name on 3 lines",
fr => "et en français",
},
long =>
{ chain => { empty => '', not => { empty => 'zlonk powie' } } },
now => {
test => {
the =>
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.879 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )