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
|
1
|
|
|
1
|
|
15765
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
19
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
47
|
|
20
|
1
|
|
|
1
|
|
6
|
use base qw(NNexus::Index::Template); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
510
|
|
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
1
|
|
sub domain_root { "http://dlmf.nist.gov" } |
23
|
0
|
|
|
0
|
0
|
|
sub domain_base { "http://dlmf.nist.gov/" } |
24
|
0
|
|
|
0
|
1
|
|
sub depth_limit { 100 } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub candidate_links { |
27
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
28
|
0
|
|
|
|
|
|
my $url = $self->current_url; |
29
|
0
|
|
|
|
|
|
my $dom = $self->current_dom; |
30
|
|
|
|
|
|
|
# We only care about /idx and /not pages (index and notations) |
31
|
0
|
|
|
|
|
|
my @next_jobs = $dom->find('a')->each; |
32
|
0
|
|
|
|
|
|
@next_jobs = map {s/^(\.\.\/)?\.\///; $self->domain_base . $_; } grep {/\.\/(idx|not)(\/\w?)?$/} map { $_->{href}} @next_jobs; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
\@next_jobs; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub index_page { |
37
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
38
|
0
|
|
|
|
|
|
my $url = $self->current_url; |
39
|
0
|
|
|
|
|
|
my $dom = $self->current_dom; |
40
|
0
|
|
|
|
|
|
my $name; |
41
|
0
|
|
|
|
|
|
my $category = '33-XX'; # Special functions? always? |
42
|
0
|
|
|
|
|
|
my (@def_links,@def_names); |
43
|
0
|
0
|
|
|
|
|
if ($url =~ /\/idx/) { |
|
|
0
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# DLMF Index page |
45
|
0
|
|
|
|
|
|
my $def_spans = $dom->find('div > ul > li > span > span[class="ltx_text ltx_font_bold"]'); |
46
|
0
|
|
|
|
|
|
@def_links = map {s/^(\.\.\/)?\.\///; $self->domain_base . $_; } map {$_->{href}} $def_spans->pluck('a')->each; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
@def_names = map { |
48
|
0
|
|
|
|
|
|
my $t = $_->children->first->content; |
49
|
0
|
|
|
|
|
|
$t =~ s/\(.+\)//g; |
50
|
0
|
|
|
|
|
|
$t =~ s/\:(.*)$//; |
51
|
0
|
|
|
|
|
|
$t;} |
52
|
|
|
|
|
|
|
$def_spans->pluck('parent')->pluck('parent')->each; |
53
|
|
|
|
|
|
|
} elsif ($url =~ /\/not/) { |
54
|
0
|
|
|
|
|
|
my $def_anchors = $dom->find('a[class="ltx_ref"]'); |
55
|
0
|
|
|
|
|
|
@def_links = map {s/^(.+)\.\///; $self->domain_base . $_; } map {$_->{href}} $def_anchors->each; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
@def_names = $def_anchors->pluck('parent')->pluck('content')->each; |
57
|
0
|
|
|
|
|
|
@def_names = map {my ($name) = split(';',$_); $name;} @def_names; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# DLMF Notation page |
59
|
|
|
|
|
|
|
} else { |
60
|
|
|
|
|
|
|
# Default is empty! |
61
|
0
|
|
|
|
|
|
return []; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $results=[]; |
65
|
0
|
|
0
|
|
|
|
while (@def_links && @def_names) { |
66
|
0
|
|
|
|
|
|
my ($name,$link)=(shift @def_names, shift @def_links); |
67
|
0
|
|
|
|
|
|
push @$results, {url=>$link,concept=>$name,categories=>[$category]}; |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
return $results; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
__END__ |