documentcloud 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 85624f45e49e63cca8533313979668d61170ff70
4
+ data.tar.gz: 8262d41db09bac2fed94a9f9e3fc1452ffa99323
5
+ SHA512:
6
+ metadata.gz: 367417f221e27d26c82dae344bed4a1a791df1dc113bea75a4a1b76f424ca4e998a378a5b63dc1309b1c1fbc555d4f4bf8766f0fd2c611d889d2848aa89495ed
7
+ data.tar.gz: df90ed5492641788f203b12406173c9cfcf350815598aae63d25a8057087495063344285f3c3633c204fb1a6202a51217d52ec1798c0db1b201a4a11c5e170ad
data/README.md CHANGED
@@ -81,6 +81,7 @@ doc.print_annotations
81
81
  doc.related_article
82
82
  doc.text # Raw parsed text from document
83
83
  doc.thumbnail # Primary thumbnail of document
84
+ doc.entities # Returns a hash of entities and their relevance
84
85
 
85
86
  # Images
86
87
  doc.image(page, size) # Returns the image of a page at the specified size
@@ -102,8 +103,51 @@ results.documents # Array of documents of results:
102
103
  results.documents[0].title # First result title
103
104
  ```
104
105
 
106
+ ### Projects
107
+ Projects returns an array of Project objects which contain a list of Documents and
108
+ metadata about the project.
109
+
110
+ ```ruby
111
+ projects = DocumentCloud.projects
112
+
113
+ project = projects.first
114
+
115
+ # Accessors
116
+ project.id
117
+ project.title
118
+ project.description
119
+ project.documents # Returns an array of Document objects
120
+ ```
121
+
122
+ ### Entities
123
+ Entities takes a document id and returns a hash of entities, which
124
+ include a value and relevance for each type of entity.
125
+
126
+ ```ruby
127
+ entities = DocumentCloud.entities(2072158)
128
+
129
+ # example output
130
+ {
131
+ :person=>[{:value=>"Pita Sharples", :relevance=>0.112}],
132
+ :organization=>[{:value=>"Māori Party", :relevance=>0.48}],
133
+ :place=>[],
134
+ :term=>
135
+ [{:value=>"finance costs", :relevance=>0.552},
136
+ {:value=>"public services", :relevance=>0.526}],
137
+ :email=>[],
138
+ :phone=>[],
139
+ :city=>[],
140
+ :state=>[],
141
+ :country=>
142
+ [{:value=>"New Zealand", :relevance=>0.628},
143
+ {:value=>"Australia", :relevance=>0.302},
144
+ {:value=>"United States", :relevance=>0.295},
145
+ {:value=>"United Kingdom", :relevance=>0.295},
146
+ {:value=>"China", :relevance=>0.294}]
147
+ }
148
+ ```
105
149
 
106
150
 
107
151
  ## Information
108
152
 
109
- DocumentCloud API info: http://www.documentcloud.org/help/api
153
+ DocumentCloud API info: http://www.documentcloud.org/help/api
@@ -14,9 +14,9 @@ module DocumentCloud
14
14
  private
15
15
 
16
16
  def document_path(document_id)
17
- "#{DOCUMENT_PATH}/#{document_id.to_s}.json"
17
+ "#{DOCUMENT_PATH}/#{document_id.to_i}.json"
18
18
  end
19
19
 
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -15,9 +15,9 @@ module DocumentCloud
15
15
  private
16
16
 
17
17
  def document_path(document_id)
18
- "#{DOCUMENT_PATH}/#{document_id.to_s}.json"
18
+ "#{DOCUMENT_PATH}/#{document_id.to_i}.json"
19
19
  end
20
20
 
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -16,9 +16,9 @@ module DocumentCloud
16
16
  private
17
17
 
18
18
  def entities_path(document_id)
19
- "#{DOCUMENT_PATH}/#{document_id.to_s}/#{ENTITIES_PATH}"
19
+ "#{DOCUMENT_PATH}/#{document_id.to_i}/#{ENTITIES_PATH}"
20
20
  end
21
21
 
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -6,10 +6,10 @@ module DocumentCloud
6
6
 
7
7
  # List projects
8
8
  #
9
- # @returns [Hash] The fetched document entities
9
+ # @returns [DocumentCloud::Project] An array of fetched project entities
10
10
  def projects
11
11
  build_objects DocumentCloud::Project, get(PROJECTS_PATH)
12
12
  end
13
13
  end
14
14
  end
15
- end
15
+ end
@@ -24,9 +24,9 @@ module DocumentCloud
24
24
  private
25
25
 
26
26
  def document_path(document_id)
27
- "#{DOCUMENT_PATH}/#{document_id.to_s}.json"
27
+ "#{DOCUMENT_PATH}/#{document_id.to_i}.json"
28
28
  end
29
29
 
30
30
  end
31
31
  end
32
- end
32
+ end
@@ -20,9 +20,9 @@ module DocumentCloud
20
20
  private
21
21
 
22
22
  def project_path(project_id)
23
- "#{PROJECT_PATH}/#{project_id.to_s}.json"
23
+ "#{PROJECT_PATH}/#{project_id.to_i}.json"
24
24
  end
25
25
 
26
26
  end
27
27
  end
28
- end
28
+ end
@@ -2,7 +2,7 @@ module DocumentCloud
2
2
  class Version
3
3
  MAJOR = 0 unless defined? DocumentCloud::Version::MAJOR
4
4
  MINOR = 3 unless defined? DocumentCloud::Version::MINOR
5
- PATCH = 1 unless defined? DocumentCloud::Version::PATCH
5
+ PATCH = 2 unless defined? DocumentCloud::Version::PATCH
6
6
  PRE = nil unless defined? DocumentCloud::Version::PRE
7
7
 
8
8
  class << self
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: documentcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
5
- prerelease:
4
+ version: 0.3.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Miles Zimmerman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-11-07 00:00:00.000000000 Z
11
+ date: 2016-02-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rest-client
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - "~>"
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: multi_json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - "~>"
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - "~>"
44
39
  - !ruby/object:Gem::Version
@@ -53,6 +48,7 @@ files:
53
48
  - LICENSE
54
49
  - README.md
55
50
  - documentcloud.gemspec
51
+ - lib/document_cloud.rb
56
52
  - lib/document_cloud/api/create_project.rb
57
53
  - lib/document_cloud/api/destroy.rb
58
54
  - lib/document_cloud/api/document.rb
@@ -70,32 +66,29 @@ files:
70
66
  - lib/document_cloud/project.rb
71
67
  - lib/document_cloud/search_results.rb
72
68
  - lib/document_cloud/version.rb
73
- - lib/document_cloud.rb
74
69
  - lib/documentcloud.rb
75
70
  homepage: https://github.com/mileszim/documentcloud
76
71
  licenses:
77
72
  - MIT
73
+ metadata: {}
78
74
  post_install_message:
79
75
  rdoc_options: []
80
76
  require_paths:
81
77
  - lib
82
78
  required_ruby_version: !ruby/object:Gem::Requirement
83
- none: false
84
79
  requirements:
85
80
  - - ">="
86
81
  - !ruby/object:Gem::Version
87
82
  version: '0'
88
83
  required_rubygems_version: !ruby/object:Gem::Requirement
89
- none: false
90
84
  requirements:
91
85
  - - ">="
92
86
  - !ruby/object:Gem::Version
93
87
  version: '0'
94
88
  requirements: []
95
89
  rubyforge_project:
96
- rubygems_version: 1.8.25
90
+ rubygems_version: 2.5.1
97
91
  signing_key:
98
- specification_version: 3
92
+ specification_version: 4
99
93
  summary: Rubygem for interacting with the DocumentCloud API
100
94
  test_files: []
101
- has_rdoc: