line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# /=====================================================================\ # |
2
|
|
|
|
|
|
|
# | NNexus Autolinker | # |
3
|
|
|
|
|
|
|
# | Indexing Plug-in, DLMF.nist.gov domain | # |
4
|
|
|
|
|
|
|
# |=====================================================================| # |
5
|
|
|
|
|
|
|
# | Part of the Planetary project: http://trac.mathweb.org/planetary | # |
6
|
|
|
|
|
|
|
# | Research software, produced as part of work done by: | # |
7
|
|
|
|
|
|
|
# | the KWARC group at Jacobs University | # |
8
|
|
|
|
|
|
|
# | Copyright (c) 2012 | # |
9
|
|
|
|
|
|
|
# | Released under the MIT License (MIT) | # |
10
|
|
|
|
|
|
|
# |---------------------------------------------------------------------| # |
11
|
|
|
|
|
|
|
# | Adapted from the original NNexus code by | # |
12
|
|
|
|
|
|
|
# | James Gardner and Aaron Krowne | # |
13
|
|
|
|
|
|
|
# |---------------------------------------------------------------------| # |
14
|
|
|
|
|
|
|
# | Deyan Ginev #_# | # |
15
|
|
|
|
|
|
|
# | http://kwarc.info/people/dginev (o o) | # |
16
|
|
|
|
|
|
|
# \=========================================================ooo==U==ooo=/ # |
17
|
|
|
|
|
|
|
package NNexus::Index::Dlmf; |
18
|
2
|
|
|
2
|
|
14662
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
72
|
|
19
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
68
|
|
20
|
2
|
|
|
2
|
|
8
|
use base qw(NNexus::Index::Template); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1270
|
|
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
1
|
0
|
sub domain_root { "http://dlmf.nist.gov" } |
23
|
29
|
|
|
29
|
0
|
66
|
sub domain_base { "http://dlmf.nist.gov/" } |
24
|
2
|
|
|
2
|
1
|
7
|
sub depth_limit { 100 } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub candidate_links { |
27
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
28
|
1
|
|
|
|
|
5
|
my $url = $self->current_url; |
29
|
1
|
|
|
|
|
5
|
my $dom = $self->current_dom; |
30
|
|
|
|
|
|
|
# We only care about /idx and /not pages (index and notations) |
31
|
1
|
|
|
|
|
3
|
my @next_jobs = $dom->find('a')->each; |
32
|
1
|
|
|
|
|
9982
|
@next_jobs = map {s/^(\.\.\/)?\.\///; $self->domain_base . $_; } grep {/\.\/(idx|not)(\/\w?)?$/} map { $_->{href}} @next_jobs; |
|
28
|
|
|
|
|
42
|
|
|
28
|
|
|
|
|
26
|
|
|
122
|
|
|
|
|
163
|
|
|
122
|
|
|
|
|
1019
|
|
33
|
1
|
|
|
|
|
8
|
\@next_jobs; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub index_page { |
37
|
1
|
|
|
1
|
1
|
1
|
my ($self) = @_; |
38
|
1
|
|
|
|
|
3
|
my $url = $self->current_url; |
39
|
1
|
|
|
|
|
3
|
my $dom = $self->current_dom; |
40
|
1
|
|
|
|
|
1
|
my $name; |
41
|
1
|
|
|
|
|
1
|
my $category = '33-XX'; # Special functions? always? |
42
|
1
|
|
|
|
|
1
|
my (@def_links,@def_names); |
43
|
1
|
50
|
|
|
|
5
|
if ($url =~ /\/idx/) { |
|
|
0
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# DLMF Index page |
45
|
1
|
|
|
|
|
3
|
my $def_spans = $dom->find('div > ul > li > span > span[class="ltx_text ltx_font_bold"]'); |
46
|
1
|
|
|
1
|
|
10992
|
@def_links = map {s/^(\.\.\/)?\.\///; $self->domain_base . $_; } map {$_->attr('href')} $def_spans->map(sub{$_->find('a')->each})->each; |
|
1
|
|
|
|
|
20
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
222
|
|
|
1
|
|
|
|
|
8
|
|
47
|
1
|
|
|
|
|
91
|
@def_names = map { |
48
|
1
|
|
|
|
|
6
|
my $t = $_->children->first->content; |
49
|
1
|
|
|
|
|
135
|
$t =~ s/\(.+\)//g; |
50
|
1
|
|
|
|
|
1
|
$t =~ s/\:(.*)$//; |
51
|
1
|
|
|
|
|
4
|
$t;} |
52
|
|
|
|
|
|
|
$def_spans->map('parent')->map('parent')->each; |
53
|
|
|
|
|
|
|
} elsif ($url =~ /\/not/) { |
54
|
0
|
|
|
|
|
0
|
my $def_anchors = $dom->find('a[class="ltx_ref"]'); |
55
|
0
|
|
|
|
|
0
|
@def_links = map {s/^(.+)\.\///; $self->domain_base . $_; } map {$_->{href}} $def_anchors->each; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
56
|
0
|
|
|
|
|
0
|
@def_names = $def_anchors->map('parent')->map('content')->each; |
57
|
0
|
|
|
|
|
0
|
@def_names = map {my ($name) = split(';',$_); $name;} @def_names; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
58
|
|
|
|
|
|
|
# DLMF Notation page |
59
|
|
|
|
|
|
|
} else { |
60
|
|
|
|
|
|
|
# Default is empty! |
61
|
0
|
|
|
|
|
0
|
return []; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
3
|
my $results=[]; |
65
|
1
|
|
66
|
|
|
8
|
while (@def_links && @def_names) { |
66
|
1
|
|
|
|
|
1
|
my ($name,$link)=(shift @def_names, shift @def_links); |
67
|
1
|
|
|
|
|
7
|
push @$results, {url=>$link,concept=>$name,categories=>[$category]}; |
68
|
|
|
|
|
|
|
} |
69
|
1
|
|
|
|
|
4
|
return $results; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
__END__ |