wordcloud 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/wordcloud.rb +33 -8
  3. metadata +7 -10
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e104cfde39b4429f39fdd9b205d8cdb5b25ceb21
4
+ data.tar.gz: 1fb5ce8ef370b32b9bd5b72e09bd594390d42e40
5
+ SHA512:
6
+ metadata.gz: cf6a34b40ccd90462e4424999ccbb944120c00328aab0312977dbb961c14faf785c245811f9c27453c740e56fbd0d416a5abb9a526cd6fff5e33592a588fd160
7
+ data.tar.gz: 4ac909d2524798ef5c80878543014e63d117cb2f5101ddc19a6fcddee8708d8e5d7d0593a2e62609afa7fd294957f1298a90abd8aec11cd5a7c49c2a5fbcba78
@@ -1,17 +1,18 @@
1
1
  require 'json'
2
2
 
3
3
  class WordCloud
4
- def initialize(input)
4
+ def initialize(input, type)
5
5
  @input = JSON.parse(input)
6
6
  @output = ""
7
7
  @wordhash = Hash.new
8
+ @type = type
8
9
  end
9
10
 
10
11
  # Splits corpus on words
11
12
  def parse
12
13
  docnum = 0
13
- @input.each do |i|
14
- i.each do |j|
14
+ if @type == "single"
15
+ @input.each do |j|
15
16
  if (j[1] != nil) && (j[1].is_a? String)
16
17
  splitinput = j[1].split(" ")
17
18
  splitinput.each do |w|
@@ -21,12 +22,10 @@ class WordCloud
21
22
  wordCount(w)
22
23
  end
23
24
  end
25
+ docnum += 1
24
26
  end
25
- docnum += 1
26
- end
27
27
 
28
- @input.each do |i|
29
- i.each do |j|
28
+ @input.each do |j|
30
29
  if (j[1] != nil) && (j[1].is_a? String)
31
30
  @output = @output + "<b>" + j[0] + ": " + "</b>" + genOutput(j[1], docnum) + "<br />"
32
31
  else
@@ -34,6 +33,33 @@ class WordCloud
34
33
  end
35
34
  end
36
35
  @output = @output + "<br />"
36
+
37
+ elsif @type == "multiple"
38
+ @input.each do |i|
39
+ i.each do |j|
40
+ if (j[1] != nil) && (j[1].is_a? String)
41
+ splitinput = j[1].split(" ")
42
+ splitinput.each do |w|
43
+ if w.include? "\\n"
44
+ w.gsub!("\\n", "<br />")
45
+ end
46
+ wordCount(w)
47
+ end
48
+ end
49
+ end
50
+ docnum += 1
51
+ end
52
+
53
+ @input.each do |i|
54
+ i.each do |j|
55
+ if (j[1] != nil) && (j[1].is_a? String)
56
+ @output = @output + "<b>" + j[0] + ": " + "</b>" + genOutput(j[1], docnum) + "<br />"
57
+ else
58
+ @output = @output + "<b>" + j[0] + ": " + "</b>" + j[1].to_s + "<br />"
59
+ end
60
+ end
61
+ @output = @output + "<br />"
62
+ end
37
63
  end
38
64
  return @output
39
65
  end
@@ -85,4 +111,3 @@ class WordCloud
85
111
  return output
86
112
  end
87
113
  end
88
-
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
5
- prerelease:
4
+ version: 0.0.11
6
5
  platform: ruby
7
6
  authors:
8
7
  - M. C. McGrath
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-29 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Takes input and outputs the same text with word size changed based on
15
14
  frequency.
@@ -22,27 +21,25 @@ files:
22
21
  homepage: http://transparencytoolkit.org
23
22
  licenses:
24
23
  - GPL
24
+ metadata: {}
25
25
  post_install_message:
26
26
  rdoc_options: []
27
27
  require_paths:
28
28
  - lib
29
29
  required_ruby_version: !ruby/object:Gem::Requirement
30
- none: false
31
30
  requirements:
32
- - - ! '>='
31
+ - - '>='
33
32
  - !ruby/object:Gem::Version
34
33
  version: '0'
35
34
  required_rubygems_version: !ruby/object:Gem::Requirement
36
- none: false
37
35
  requirements:
38
- - - ! '>='
36
+ - - '>='
39
37
  - !ruby/object:Gem::Version
40
38
  version: '0'
41
39
  requirements: []
42
40
  rubyforge_project:
43
- rubygems_version: 1.8.23
41
+ rubygems_version: 2.0.14
44
42
  signing_key:
45
- specification_version: 3
43
+ specification_version: 4
46
44
  summary: Outputs text with word size determined by their frequency
47
45
  test_files: []
48
- has_rdoc: