| 1 | use Data::Printer; | ||
| 2 | use Data::Dumper; | ||
| 3 | use AI::MicroStructure; | ||
| 4 | use Search::ContextGraph; | ||
| 5 | my $meta = AI::MicroStructure->new( "ufo" ); | ||
| 6 | |||
| 7 | BEGIN{ | ||
| 8 | |||
| 9 | our $all = {dir =>shift,store =>shift}; | ||
| 10 | |||
| 11 | |||
| 12 | }; | ||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | sub ret{ | ||
| 17 | my $dir = shift; | ||
| 18 | |||
| 19 | #die() unless(-d $dir); | ||
| 20 | |||
| 21 | my $cg = Search::ContextGraph->load_from_dir( $dir ); | ||
| 22 | |||
| 23 | |||
| 24 | |||
| 25 | return $cg; | ||
| 26 | |||
| 27 | } | ||
| 28 | |||
| 29 | |||
| 30 | sub store{ | ||
| 31 | |||
| 32 | my $file = shift; | ||
| 33 | |||
| 34 | die() unless(-f $file); | ||
| 35 | |||
| 36 | |||
| 37 | $cg->store( $file); | ||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | my $cg = Search::ContextGraph->retrieve($file); | ||
| 42 | |||
| 43 | return $cg; | ||
| 44 | |||
| 45 | } | ||
| 46 | |||
| 47 | ret($all->{dir}); | ||
| 48 | store($all->{store}); | ||
| 49 | |||
| 50 | |||
| 51 | my ( @docs, $words ) = | ||
| 52 | $cg->mixed_search( | ||
| 53 | {docs=>[$cg->doc_list()], | ||
| 54 | terms => ['genetic', | ||
| 55 | 'dreaming', | ||
| 56 | 'evolutionary']}); | ||
| 57 | |||
| 58 | p @{[@docs,[keys %$words]]}; |