| 1 | package DMOSS::Plugin::AutoClassify; | ||||||||||||||||||||||||||||
| 2 | 1 | $DMOSS::Plugin::AutoClassify::VERSION = '0.01_2'; | |||||||||||||||||||||||||||
| 3 | # ABSTRACT: DMOSS classification plugin | ||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use parent qw/DMOSS::Plugin/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use URI::Find; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use File::Slurp qw/read_file/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use HTTP::Request; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | our @types = qw/_PACKAGE/; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # taxonomy | ||||||||||||||||||||||||||||
| 17 | 1 | my $tax = { | |||||||||||||||||||||||||||
| 18 | 'audio video' => { | ||||||||||||||||||||||||||||
| 19 | 'sound audio' => 1, | ||||||||||||||||||||||||||||
| 20 | 'video' => 1, | ||||||||||||||||||||||||||||
| 21 | }, | ||||||||||||||||||||||||||||
| 22 | 'business enterprise' => { | ||||||||||||||||||||||||||||
| 23 | 'scheduling' => 1, | ||||||||||||||||||||||||||||
| 24 | 'office suites' => 1, | ||||||||||||||||||||||||||||
| 25 | 'e-commerce shopping' => 1, | ||||||||||||||||||||||||||||
| 26 | 'desktop publisinhg' => 1, | ||||||||||||||||||||||||||||
| 27 | 'report generators' => 1, | ||||||||||||||||||||||||||||
| 28 | 'knowledge management' => 1, | ||||||||||||||||||||||||||||
| 29 | 'enterprise' => 1, | ||||||||||||||||||||||||||||
| 30 | 'financial' => 1, | ||||||||||||||||||||||||||||
| 31 | 'todo lists' => 1, | ||||||||||||||||||||||||||||
| 32 | 'modelling' => 1, | ||||||||||||||||||||||||||||
| 33 | 'project management' => 1, | ||||||||||||||||||||||||||||
| 34 | 'time tracking' => 1, | ||||||||||||||||||||||||||||
| 35 | 'insurance' => 1, | ||||||||||||||||||||||||||||
| 36 | }, | ||||||||||||||||||||||||||||
| 37 | 'communications' => { | ||||||||||||||||||||||||||||
| 38 | 'chat' => 1, | ||||||||||||||||||||||||||||
| 39 | 'rss feed readers ' => 1, | ||||||||||||||||||||||||||||
| 40 | 'bbs' => 1, | ||||||||||||||||||||||||||||
| 41 | 'conferencing' => 1, | ||||||||||||||||||||||||||||
| 42 | 'email' => 1, | ||||||||||||||||||||||||||||
| 43 | 'fax' => 1, | ||||||||||||||||||||||||||||
| 44 | 'fido' => 1, | ||||||||||||||||||||||||||||
| 45 | 'ham radio' => 1, | ||||||||||||||||||||||||||||
| 46 | 'usenet news' => 1, | ||||||||||||||||||||||||||||
| 47 | 'internet phone' => 1, | ||||||||||||||||||||||||||||
| 48 | 'synchronization' => 1, | ||||||||||||||||||||||||||||
| 49 | 'streaming' => 1, | ||||||||||||||||||||||||||||
| 50 | 'telephony' => 1, | ||||||||||||||||||||||||||||
| 51 | 'file sharing' => 1, | ||||||||||||||||||||||||||||
| 52 | }, | ||||||||||||||||||||||||||||
| 53 | 'development' => { | ||||||||||||||||||||||||||||
| 54 | 'software development' => 1, | ||||||||||||||||||||||||||||
| 55 | 'database' => 1, | ||||||||||||||||||||||||||||
| 56 | 'text editors' => 1, | ||||||||||||||||||||||||||||
| 57 | 'data formats' => 1, | ||||||||||||||||||||||||||||
| 58 | }, | ||||||||||||||||||||||||||||
| 59 | 'home education' => { | ||||||||||||||||||||||||||||
| 60 | 'religion philosophy' => 1, | ||||||||||||||||||||||||||||
| 61 | 'education' => 1, | ||||||||||||||||||||||||||||
| 62 | 'printing' => 1, | ||||||||||||||||||||||||||||
| 63 | 'social sciences' => 1, | ||||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||
| 65 | 'games' => { | ||||||||||||||||||||||||||||
| 66 | 'hobbies' => 1, | ||||||||||||||||||||||||||||
| 67 | 'side-scrolling arcade' => 1, | ||||||||||||||||||||||||||||
| 68 | 'flight simulator' => 1, | ||||||||||||||||||||||||||||
| 69 | 'sports' => 1, | ||||||||||||||||||||||||||||
| 70 | 'mmorpg' => 1, | ||||||||||||||||||||||||||||
| 71 | 'puzzle' => 1, | ||||||||||||||||||||||||||||
| 72 | 'real time tactical' => 1, | ||||||||||||||||||||||||||||
| 73 | 'real time strategy' => 1, | ||||||||||||||||||||||||||||
| 74 | 'first person shooter' => 1, | ||||||||||||||||||||||||||||
| 75 | 'turn base strategy' => 1, | ||||||||||||||||||||||||||||
| 76 | 'role-playing' => 1, | ||||||||||||||||||||||||||||
| 77 | 'card games' => 1, | ||||||||||||||||||||||||||||
| 78 | 'multi user dungeon' => 1, | ||||||||||||||||||||||||||||
| 79 | 'console based' => 1, | ||||||||||||||||||||||||||||
| 80 | 'development framework' => 1, | ||||||||||||||||||||||||||||
| 81 | 'multiplayer' => 1, | ||||||||||||||||||||||||||||
| 82 | 'simulation' => 1, | ||||||||||||||||||||||||||||
| 83 | 'board games' => 1, | ||||||||||||||||||||||||||||
| 84 | }, | ||||||||||||||||||||||||||||
| 85 | 'graphics' => { | ||||||||||||||||||||||||||||
| 86 | 'capture' => 1, | ||||||||||||||||||||||||||||
| 87 | 'conversion' => 1, | ||||||||||||||||||||||||||||
| 88 | 'editors' => 1, | ||||||||||||||||||||||||||||
| 89 | '3d modeling' => 1, | ||||||||||||||||||||||||||||
| 90 | '3d rendering', => 1, | ||||||||||||||||||||||||||||
| 91 | 'fractals procedural generation' => 1, | ||||||||||||||||||||||||||||
| 92 | 'viewers' => 1, | ||||||||||||||||||||||||||||
| 93 | 'image galleries' => 1, | ||||||||||||||||||||||||||||
| 94 | 'presentation' => 1, | ||||||||||||||||||||||||||||
| 95 | 'handwriting recognition' => 1, | ||||||||||||||||||||||||||||
| 96 | 'animation' => 1, | ||||||||||||||||||||||||||||
| 97 | }, | ||||||||||||||||||||||||||||
| 98 | 'science engineering' => { | ||||||||||||||||||||||||||||
| 99 | 'chemistry' => 1, | ||||||||||||||||||||||||||||
| 100 | 'information analysis' => 1, | ||||||||||||||||||||||||||||
| 101 | 'interface engine' => 1, | ||||||||||||||||||||||||||||
| 102 | 'protocol translator' => 1, | ||||||||||||||||||||||||||||
| 103 | 'physics' => 1, | ||||||||||||||||||||||||||||
| 104 | 'artificial intelligence' => 1, | ||||||||||||||||||||||||||||
| 105 | 'astronomy' => 1, | ||||||||||||||||||||||||||||
| 106 | 'visualization' => 1, | ||||||||||||||||||||||||||||
| 107 | 'mapping' => 1, | ||||||||||||||||||||||||||||
| 108 | 'medical' => 1, | ||||||||||||||||||||||||||||
| 109 | 'mechanical civil engineering' => 1, | ||||||||||||||||||||||||||||
| 110 | 'human machine interfaces' => 1, | ||||||||||||||||||||||||||||
| 111 | 'medical physics' => 1, | ||||||||||||||||||||||||||||
| 112 | 'molecular mechanics' => 1, | ||||||||||||||||||||||||||||
| 113 | 'quantum computing' => 1, | ||||||||||||||||||||||||||||
| 114 | 'earth ' => 1, | ||||||||||||||||||||||||||||
| 115 | 'ecosystem ' => 1, | ||||||||||||||||||||||||||||
| 116 | 'test measurement' => 1, | ||||||||||||||||||||||||||||
| 117 | 'molecular' => 1, | ||||||||||||||||||||||||||||
| 118 | 'building automation' => 1, | ||||||||||||||||||||||||||||
| 119 | 'simulators' => 1, | ||||||||||||||||||||||||||||
| 120 | 'robotics' => 1, | ||||||||||||||||||||||||||||
| 121 | 'scada' => 1, | ||||||||||||||||||||||||||||
| 122 | 'mathematics' => 1, | ||||||||||||||||||||||||||||
| 123 | 'linguistics' => 1, | ||||||||||||||||||||||||||||
| 124 | 'electronic design automation' => 1, | ||||||||||||||||||||||||||||
| 125 | 'bio-informatics' => 1, | ||||||||||||||||||||||||||||
| 126 | }, | ||||||||||||||||||||||||||||
| 127 | 'security utilities' => { | ||||||||||||||||||||||||||||
| 128 | 'archiving' => 1, | ||||||||||||||||||||||||||||
| 129 | 'file management' => 1, | ||||||||||||||||||||||||||||
| 130 | 'power ups' => 1, | ||||||||||||||||||||||||||||
| 131 | 'terminals' => 1, | ||||||||||||||||||||||||||||
| 132 | 'security' => 1, | ||||||||||||||||||||||||||||
| 133 | 'log rotation' => 1, | ||||||||||||||||||||||||||||
| 134 | 'file transfer protocol' => 1, | ||||||||||||||||||||||||||||
| 135 | 'capture' => 1, | ||||||||||||||||||||||||||||
| 136 | 'log analysis' => 1, | ||||||||||||||||||||||||||||
| 137 | }, | ||||||||||||||||||||||||||||
| 138 | 'system administration' => { | ||||||||||||||||||||||||||||
| 139 | 'software distribution' => 1, | ||||||||||||||||||||||||||||
| 140 | 'benchmark' => 1, | ||||||||||||||||||||||||||||
| 141 | 'boot' => 1, | ||||||||||||||||||||||||||||
| 142 | 'clustering' => 1, | ||||||||||||||||||||||||||||
| 143 | 'file system' => 1, | ||||||||||||||||||||||||||||
| 144 | 'emedded sustem' => 1, | ||||||||||||||||||||||||||||
| 145 | 'operation system kernel' => 1, | ||||||||||||||||||||||||||||
| 146 | 'cron scheduling' => 1, | ||||||||||||||||||||||||||||
| 147 | 'instalattion' => 1, | ||||||||||||||||||||||||||||
| 148 | 'logging' => 1, | ||||||||||||||||||||||||||||
| 149 | 'networking' => 1, | ||||||||||||||||||||||||||||
| 150 | 'power ups' => 1, | ||||||||||||||||||||||||||||
| 151 | 'home automation' => 1, | ||||||||||||||||||||||||||||
| 152 | 'os distribution' => 1, | ||||||||||||||||||||||||||||
| 153 | 'system shell' => 1, | ||||||||||||||||||||||||||||
| 154 | 'distributed computing' => 1, | ||||||||||||||||||||||||||||
| 155 | 'emulators' => 1, | ||||||||||||||||||||||||||||
| 156 | 'hardware' => 1, | ||||||||||||||||||||||||||||
| 157 | 'search' => 1, | ||||||||||||||||||||||||||||
| 158 | 'storage' => 1, | ||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | }; | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub name { 'Auto Classification' } | ||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 1 | my $TMPDIR = '/tmp'; # FIXME | |||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 166 | 0 | my ($self, $dmoss, $file) = @_; | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | my $corpus = join('/', $TMPDIR, $dmoss->{meta}->{dist}) . '.txt'; | |||||||||||||||||||||||||||
| 169 | 0 | ▶ | unless (-e $corpus) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 0 | `dmoss-corpus $dmoss->{basedir} > $corpus` | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | 0 | my $c = read_file $corpus; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | # first level | ||||||||||||||||||||||||||||
| 175 | 0 | my $last = 0; | |||||||||||||||||||||||||||
| 176 | 0 | my $first; | |||||||||||||||||||||||||||
| 177 | 0 | foreach my $um (keys %$tax) { | |||||||||||||||||||||||||||
| 178 | 0 | my @words = (); | |||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ($um =~ m/\s/) { @words = split /\s+/, $um; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 0 | else { push @words, $um; } | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 0 | foreach (keys %{$tax->{$um}}) { | |||||||||||||||||||||||||||
| 183 | 0 | push @words, split /\s+/, $_; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | my $curr = findAll(@words); | |||||||||||||||||||||||||||
| 187 | 0 | ▶ | if ($curr > $last) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 0 | $last = $curr; | |||||||||||||||||||||||||||
| 189 | 0 | $first = $um | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | # second level | ||||||||||||||||||||||||||||
| 194 | 0 | my $second; | |||||||||||||||||||||||||||
| 195 | 0 | $last = 0; | |||||||||||||||||||||||||||
| 196 | 0 | foreach my $dois (keys %{$tax->{$first}}) { | |||||||||||||||||||||||||||
| 197 | 0 | my @words = (); | |||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ($dois =~ m/\s/) { @words = split /\s+/, $dois; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 0 | else { push @words, $dois; } | |||||||||||||||||||||||||||
| 200 | 0 | print Dumper \@words; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | my $curr = findAll($c, @words); | |||||||||||||||||||||||||||
| 203 | 0 | print "curr $curr\n"; | |||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ($curr > $last) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 0 | $last = $curr; | |||||||||||||||||||||||||||
| 206 | 0 | $second = $dois; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 0 | $dmoss->add_attr('auto_classify', {fst=>$first, snd=>$second}); | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 0 | ▶ | sub reduce { } | ||||||||||||||||||||||||||
|
Subroutine
reduce: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | ▶ | sub report { | ||||||||||||||||||||||||||
|
Subroutine
report: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 216 | 0 | my ($self, $dmoss, $attr) = @_; | |||||||||||||||||||||||||||
| 217 | 0 | ▶ | return unless ($attr->value and keys %{$attr->value}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$attr->value and keys %{$attr->value;}
MC/DC0%0/2
$attr->value and keys %{$attr->value;}
$attr->value
keys %{$attr->value;}
Truth table0%0/3
A and B
A= $attr->valueB= keys %{$attr->value;}
| |||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 0 | return [ $attr->value->{fst}, $attr->value->{snd} ]; | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | sub report_headers { | ||||||||||||||||||||||||||
|
Subroutine
report_headers: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 223 | 0 | my ($self, $dmoss) = @_; | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | return [ 'Class', 'Sub-class' ]; | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | ▶ | sub grade { | ||||||||||||||||||||||||||
|
Subroutine
grade: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 229 | 0 | my ($self, $dmoss, $attr) = @_; | |||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | return 1 if ($attr->value->{fst} and $attr->value->{snd}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$attr->value->{"fst"} and $attr->value->{"snd"}
MC/DC0%0/2
$attr->value->{"fst"} and $attr->value->{"snd"}
$attr->value->{"fst"}
$attr->value->{"snd"}
Truth table0%0/3
A and B
A= $attr->value->{"fst"}B= $attr->value->{"snd"}
| |||||||||||||||||||||||||||||
| 232 | 0 | ▶ | return 0.5 if ($attr->value->{fst} or $attr->value->{snd}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$attr->value->{"fst"} or $attr->value->{"snd"}
MC/DC0%0/2
$attr->value->{"fst"} or $attr->value->{"snd"}
$attr->value->{"fst"}
$attr->value->{"snd"}
Truth table0%0/3
A or B
A= $attr->value->{"fst"}B= $attr->value->{"snd"}
| |||||||||||||||||||||||||||||
| 233 | 0 | return 0; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 0 | ▶ | sub findAll { | ||||||||||||||||||||||||||
|
Subroutine
findAll: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 237 | 0 | my ($c, @words) = @_; | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | my $found = 0; | |||||||||||||||||||||||||||
| 240 | 0 | foreach (@words) { | |||||||||||||||||||||||||||
| 241 | 0 | ▶ | next unless ($_ =~ m/\w/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $found++ while ($c =~ m/\b${_}s?\b/ig); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | return $found; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 1 | 1; | |||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | __END__ | ||||||||||||||||||||||||||||