math_metadata_lookup 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -9,6 +9,9 @@ It can work with LaTeX accent notation.
|
|
9
9
|
Installation
|
10
10
|
------------
|
11
11
|
|
12
|
+
``math_metadata_lookup`` is written in Ruby. Consult your system documentation how to install ruby and rubygems,
|
13
|
+
then you can install ``math_metadata_lookup`` using rubygems:
|
14
|
+
|
12
15
|
gem install math_metadata_lookup
|
13
16
|
|
14
17
|
|
@@ -35,12 +38,16 @@ Usage from ruby
|
|
35
38
|
|
36
39
|
require 'rubygems'
|
37
40
|
require 'math_metadata_lookup'
|
38
|
-
|
41
|
+
|
39
42
|
# initialize search engine to look only to Mathematical Reviews database
|
40
|
-
l = MathMetadata
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
l = MathMetadata::Lookup.new( :sites => [:mr], :verbose => false )
|
44
|
+
|
45
|
+
# fetch result
|
46
|
+
mr_result = l.article( :title => "Sobolev embeddings with variable exponent. II" ).first
|
47
|
+
article = mr_result[:result].first
|
48
|
+
|
49
|
+
# print out article authors separated with semicolon
|
50
|
+
puts article[:authors].join("; ")
|
44
51
|
|
45
52
|
|
46
53
|
Resources
|
@@ -59,11 +66,11 @@ Function reference
|
|
59
66
|
Hash arguments are:
|
60
67
|
|
61
68
|
* article id is known
|
62
|
-
* **:id**
|
69
|
+
* **:id** String
|
63
70
|
* article id is unknown
|
64
71
|
* **:title** String
|
65
|
-
* **:authors** Array of
|
66
|
-
* **:year**
|
72
|
+
* **:authors** Array of Strings
|
73
|
+
* **:year** String
|
67
74
|
|
68
75
|
Returns instance of class Result.
|
69
76
|
|
@@ -90,7 +97,7 @@ The Levenshtein distance function is run on full given title and full given name
|
|
90
97
|
Hash arguments are:
|
91
98
|
|
92
99
|
* **:title** String
|
93
|
-
* **:author** Array of
|
100
|
+
* **:author** Array of Strings
|
94
101
|
* **:year** String
|
95
102
|
* **:threshold** Float. Range: 0.0...1.0. Default: 0.6
|
96
103
|
|
@@ -111,35 +111,41 @@ Ref.: #{idx+1}. #{[a[:authors]].flatten.join("; ")}: #{a[:title]}~
|
|
111
111
|
def to_html
|
112
112
|
result = %~
|
113
113
|
<div class="article">
|
114
|
-
Id
|
115
|
-
Publication
|
116
|
-
Title
|
117
|
-
Authors
|
118
|
-
Year
|
119
|
-
Language
|
120
|
-
MSC
|
121
|
-
Pages
|
122
|
-
ISSN
|
123
|
-
Keywords
|
124
|
-
<a href="javascript:toggle_references('ref#{@metadata[:id]}')">References >>></a>
|
125
|
-
<div id="ref#{@metadata[:id]}" name="ref#{@metadata[:id]}"class="references">
|
114
|
+
<span class="label">Id:</span> <span class="id">#{::CGI.escapeHTML @metadata[:id].to_s}</span><br />
|
115
|
+
<span class="label">Publication:</span> <span class="publication">#{::CGI.escapeHTML @metadata[:publication].to_s}</span><br />
|
116
|
+
<span class="label">Title:</span> <span class="title">#{::CGI.escapeHTML @metadata[:title].to_s}</span><br />
|
117
|
+
<span class="label">Authors:</span> <span class="authors">#{::CGI.escapeHTML @metadata[:authors].to_a.join("; ")}</span><br />
|
118
|
+
<span class="label">Year:</span> <span class="year">#{::CGI.escapeHTML @metadata[:year].to_s}</span><br />
|
119
|
+
<span class="label">Language:</span> <span class="lang">#{::CGI.escapeHTML @metadata[:language].to_s}</span><br />
|
120
|
+
<span class="label">MSC:</span> <span class="msc">#{::CGI.escapeHTML @metadata[:msc].to_a.join("; ")}</span><br />
|
121
|
+
<span class="label">Pages:</span> <span class="pages">#{::CGI.escapeHTML @metadata[:range].to_s}</span><br />
|
122
|
+
<span class="label">ISSN:</span> <span class="issn">#{::CGI.escapeHTML @metadata[:issn].to_a.join('; ')}</span><br />
|
123
|
+
<span class="label">Keywords:</span> <span class="keywords">#{::CGI.escapeHTML @metadata[:keywords].to_a.join('; ')}</span><br />
|
126
124
|
~
|
127
|
-
@metadata[:references].to_a.
|
128
|
-
ref = reference.article
|
125
|
+
if @metadata[:references].to_a.size > 0
|
129
126
|
result += %~
|
127
|
+
<a href="javascript:toggle_references('ref#{@metadata[:id]}')">References >>></a>
|
128
|
+
<div id="ref#{@metadata[:id]}" name="ref#{@metadata[:id]}" class="references">
|
129
|
+
~
|
130
|
+
@metadata[:references].to_a.each_with_index do |reference, idx|
|
131
|
+
ref = reference.article
|
132
|
+
result += %~
|
130
133
|
<div class="reference">
|
131
|
-
Source
|
132
|
-
Authors
|
133
|
-
Title
|
134
|
-
Publication
|
135
|
-
Publisher
|
136
|
-
Year
|
137
|
-
Id
|
134
|
+
<span class="label">Source:</span> <span class="source">#{::CGI.escapeHTML reference.source.to_s}</span><br />
|
135
|
+
<span class="label">Authors:</span> <span class="authors">#{::CGI.escapeHTML [ref[:authors]].flatten.join("; ")}</span><br />
|
136
|
+
<span class="label">Title:</span> <span class="title">#{::CGI.escapeHTML ref[:title].to_s}</span><br />
|
137
|
+
<span class="label">Publication:</span> <span class="publication">#{::CGI.escapeHTML ref[:publication].to_s}</span><br />
|
138
|
+
<span class="label">Publisher:</span> <span class="publisher">#{::CGI.escapeHTML ref[:publisher].to_s}</span><br />
|
139
|
+
<span class="label">Year:</span> <span class="year">#{::CGI.escapeHTML ref[:year].to_s}</span><br />
|
140
|
+
<span class="label">Id:</span> <span class="id">#{::CGI.escapeHTML ref[:id].to_s}</span><br />
|
138
141
|
</div>
|
142
|
+
~
|
143
|
+
end
|
144
|
+
result += %~
|
145
|
+
</div>
|
139
146
|
~
|
140
147
|
end
|
141
148
|
result += %~
|
142
|
-
</div>
|
143
149
|
</div>
|
144
150
|
~
|
145
151
|
result
|
@@ -31,12 +31,12 @@ Other: #{form}~
|
|
31
31
|
def to_html
|
32
32
|
result = %~
|
33
33
|
<div class="author">
|
34
|
-
<div class="author_id">Id
|
35
|
-
<div class="preferred">Preferred
|
34
|
+
<div class="author_id"><span class="label">Id:</span> <span class="id">#{::CGI.escapeHTML(@metadata[:id])}</span></div>
|
35
|
+
<div class="preferred"><span class="label">Preferred:</span> <span class="name">#{::CGI.escapeHTML(@metadata[:preferred].to_s)}</span></div>~
|
36
36
|
|
37
37
|
@metadata[:forms].each do |form|
|
38
38
|
result += %~
|
39
|
-
<div class="other">Other
|
39
|
+
<div class="other"><span class="label">Other:</span> <span class="name">#{::CGI.escapeHTML(form.to_s)}</span></div>~
|
40
40
|
end
|
41
41
|
|
42
42
|
result += %~
|
@@ -38,11 +38,11 @@ module MathMetadata
|
|
38
38
|
|
39
39
|
# try to decide what is best result for query and combine results from all sites to one article response
|
40
40
|
def heuristic( args={} )
|
41
|
-
opts = {:threshold => 0.6}.merge(args)
|
41
|
+
opts = {:threshold => 0.6, :authors => []}.merge(args)
|
42
42
|
result = Result.new
|
43
43
|
|
44
44
|
# use only authors surnames
|
45
|
-
args_dup =
|
45
|
+
args_dup = opts.dup
|
46
46
|
args_dup[:authors].map!{|a| a =~ /([^,]+)/; $1 ? $1 : a}
|
47
47
|
args_dup[:authors].map!{|a| a =~ /([^ ]+) \S+/; $1 ? $1 : a}
|
48
48
|
args_dup[:nwords] = 2
|
@@ -13,7 +13,7 @@ spec = Gem::Specification.new do |s|
|
|
13
13
|
s.email = "pejuko@gmail.com"
|
14
14
|
s.authors = ["Petr Kovar"]
|
15
15
|
s.name = 'math_metadata_lookup'
|
16
|
-
s.version = '0.1.
|
16
|
+
s.version = '0.1.4'
|
17
17
|
s.date = Time.now.strftime("%Y-%m-%d")
|
18
18
|
s.add_dependency('unicode')
|
19
19
|
s.add_dependency('unidecoder')
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: math_metadata_lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Petr Kovar
|
@@ -25,6 +26,7 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
28
30
|
segments:
|
29
31
|
- 0
|
30
32
|
version: "0"
|
@@ -38,6 +40,7 @@ dependencies:
|
|
38
40
|
requirements:
|
39
41
|
- - ">="
|
40
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
41
44
|
segments:
|
42
45
|
- 0
|
43
46
|
version: "0"
|
@@ -51,6 +54,7 @@ dependencies:
|
|
51
54
|
requirements:
|
52
55
|
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
54
58
|
segments:
|
55
59
|
- 0
|
56
60
|
version: "0"
|
@@ -99,6 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
103
|
requirements:
|
100
104
|
- - ">="
|
101
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
102
107
|
segments:
|
103
108
|
- 0
|
104
109
|
version: "0"
|
@@ -107,13 +112,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
112
|
requirements:
|
108
113
|
- - ">="
|
109
114
|
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
110
116
|
segments:
|
111
117
|
- 0
|
112
118
|
version: "0"
|
113
119
|
requirements: []
|
114
120
|
|
115
121
|
rubyforge_project:
|
116
|
-
rubygems_version: 1.
|
122
|
+
rubygems_version: 1.4.1
|
117
123
|
signing_key:
|
118
124
|
specification_version: 3
|
119
125
|
summary: Search mathematical reviews sites and fetches metadata about articles.
|