sort_rank 1.01 → 1.02

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3defac8e904ac088d9c9084fa94406aba6ad1a1c118cd2fb3759100133d2b04b
4
- data.tar.gz: 27e8582aad15dc303352d584c64d5e70a4c369e08249df0953edd973f39f7a83
3
+ metadata.gz: 0dbd1326e7f72a8e5ae1823c9dd8138a6b59e2c8f270dfaddd3a3a4c379dd3ea
4
+ data.tar.gz: f1cfd7b63627eeee34ab15ee40a2c001218fe69452407d8f8a3fc44108c49695
5
5
  SHA512:
6
- metadata.gz: d9608b8cd2f736a2d4af416830f1b4c3116c4e65f423d8b1e9e210fe7f362f9780ba30901e5a2ff487a82f62a0db90f2b733b5c9df7d9bf8356a044ebed77560
7
- data.tar.gz: 55c2f9375cff340cdd8af92286ba70d7aa092586864d47a4c5b9d9e24596ede2aaea414bcc9fff0706a7f432382d973c7e0d610b44eb61bd3544bf294bfc2363
6
+ metadata.gz: a43cbfa40eb0ecdd94ad7adebca926e80397a83c840b9bcf1a28f9c9a8ec98533c33e0fc5095f442c466e5a0c8583bb400a72eca98dd9c3ca61a2153284231f2
7
+ data.tar.gz: 287b6ba2b159098b102425f0efb0dbbe232a6d1c0b324bd52318efc778c44899c7b748e1a769c6f435a544e5f40685e993394fe2f6f7735c468fc2a0d38435fb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sort_rank (1.01)
4
+ sort_rank (1.02)
5
5
  activesupport (~> 5.2)
6
6
  crm_formatter (~> 2.64)
7
7
  mechanizer (~> 1.12)
data/README.md CHANGED
@@ -3,9 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/sort_rank.svg)](https://badge.fury.io/rb/sort_rank)
4
4
  [![MIT License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- #### Sorts and Ranks text in strings, like a full text article or document.
7
-
8
- Note: Currently being moved from local environment to this gem. Will be completed by 7/10/18
6
+ #### SortRank Sorts and Ranks text in strings, like a full text article or document.
9
7
 
10
8
  ## Installation
11
9
 
@@ -25,7 +23,29 @@ Or install it yourself as:
25
23
 
26
24
  ## Usage
27
25
 
28
- Note: Currently being moved from local environment to this gem. Will be completed by 7/10/18
26
+
27
+ 1) Add your text to a hash with `:text` symbol key, then pass the arguments to `SortRank.parse(args)` like the example below. If you don't pass any args, and just run `SortRank.parse` it will return sample data for testing.
28
+
29
+ ```
30
+ args = { text: "The state capitol in Austin, Texas Austin is a city of over 912,000 in the Hill Country of central Texas. It is the state capital and home to a major university as well as an influential center for politics, technology, music, film and increasingly a food scene. Austin's embrace of alternative cultures is commonly emblazoned about town on T-Shirts and bumper stickers that read: 'Keep Austin Weird.' Austin is also marketed as the 'Live Music Capital of the World' due to the large number of venues and 'Silicon Hills' reflecting the many technology companies." }
31
+
32
+ result_hash = SortRank.parse(args)
33
+ ```
34
+
35
+ 2) The returned data will be in hash format like below:
36
+
37
+ You can access the data, like so: `result_hash[:results]` and `result_hash[:text]`
38
+
39
+ ```
40
+ {
41
+ :results=>
42
+ {
43
+ "the"=>7, "austin"=>5, "of"=>5, "is"=>4, "and"=>4, "as"=>3, "music"=>2, "to"=>2, "technology"=>2, "capital"=>2, "texas"=>2, "in"=>2, "state"=>2, "keep"=>1, "read"=>1, "that"=>1, "stickers"=>1, "bumper"=>1, "shirts"=>1, "on"=>1, "town"=>1, "about"=>1, "emblazoned"=>1, "commonly"=>1, "cultures"=>1, "alternative"=>1, "embrace"=>1, "scene"=>1, "food"=>1, "increasingly"=>1, "film"=>1, "politics"=>1, "for"=>1, "center"=>1, "influential"=>1, "an"=>1, "well"=>1, "university"=>1, "major"=>1, "home"=>1, "it"=>1, "central"=>1, "country"=>1, "hill"=>1, "000"=>1, "912"=>1, "over"=>1, "city"=>1, "capitol"=>1, "many"=>1, "reflecting"=>1, "hills"=>1, "silicon"=>1, "venues"=>1, "number"=>1, "large"=>1, "due"=>1, "world"=>1, "live"=>1, "marketed"=>1, "also"=>1, "weird"=>1, "companies"=>1
44
+ },
45
+ :text=>
46
+ "The state capitol in Austin, Texas Austin is a city of over 912,000 in the Hill Country of central Texas. It is the state capital and home to a major university as well as an influential center for politics, technology, music, film and increasingly a food scene. Austin's embrace of alternative cultures is commonly emblazoned about town on T-Shirts and bumper stickers that read: 'Keep Austin Weird.' Austin is also marketed as the 'Live Music Capital of the World' due to the large number of venues and 'Silicon Hills' reflecting the many technology companies."
47
+ }
48
+ ```
29
49
 
30
50
  ## Development
31
51
 
data/Rakefile CHANGED
@@ -18,18 +18,18 @@ task :console do
18
18
  require "active_support/all"
19
19
  ARGV.clear
20
20
 
21
- scraped_links = run_sudoku
22
- # binding.pry
21
+ result_hash = run_sort_rank
23
22
 
24
23
  IRB.start
25
24
  end
26
25
 
27
26
 
28
- def run_sudoku
29
- binding.pry
30
- solve = SortRank::Logic.new
31
- res = solve.start
32
- binding.pry
27
+ def run_sort_rank
28
+ # args = {text: "Can a rat eat tar? How big is the arc of that car door? Could you pass me the book just below your elbow? Does your state have a coffee taste test?" }
29
+
30
+ args = { text: "The state capitol in Austin, Texas Austin is a city of over 912,000 in the Hill Country of central Texas. It is the state capital and home to a major university as well as an influential center for politics, technology, music, film and increasingly a food scene. Austin's embrace of alternative cultures is commonly emblazoned about town on T-Shirts and bumper stickers that read: 'Keep Austin Weird.' Austin is also marketed as the 'Live Music Capital of the World' due to the large number of venues and 'Silicon Hills' reflecting the many technology companies." }
31
+
32
+ result_hash = SortRank.parse(args)
33
33
 
34
34
  # scraper = LinkScraper::Scrape.new({text_criteria: text_criteria, path_criteria: path_criteria})
35
35
  # scraped_links = scraper.start('https://en.wikipedia.org/wiki/Austin%2C_Texas')
@@ -0,0 +1,30 @@
1
+
2
+ module SortRank
3
+ class Solver
4
+
5
+ # AlgoService.new.parse
6
+ def parse(args={})
7
+ string_block = args.fetch(:text, nil)
8
+ string_block = sample_string_block if !string_block.present?
9
+ result_hash = {results: count_strings(string_block), text: string_block }
10
+ end
11
+
12
+ def count_strings(string)
13
+ if string.present?
14
+ array = string.split(/\W+/)
15
+ array.map!(&:downcase)
16
+ array.reject!{|el| el.length < 2 }
17
+
18
+ string_count_hash = array.group_by{|e| e}.map{|k, v| [k, v.length]}.to_h
19
+ word_rankings = string_count_hash.sort_by {|key, value| value}.reverse!
20
+ # results = word_rankings.to_h.map { |k,v| "#{k} (#{v})" }.join(', ')
21
+ results = word_rankings.to_h
22
+ end
23
+ end
24
+
25
+ def sample_string_block
26
+ "The state capitol in Austin, Texas Austin is a city of over 912,000 in the Hill Country of central Texas. It is the state capital and home to a major university as well as an influential center for politics, technology, music, film and increasingly a food scene. Austin's embrace of alternative cultures is commonly emblazoned about town on T-Shirts and bumper stickers that read: 'Keep Austin Weird.' Austin is also marketed as the 'Live Music Capital of the World' due to the large number of venues and 'Silicon Hills' reflecting the many technology companies."
27
+ end
28
+
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module SortRank
2
- VERSION = "1.01"
2
+ VERSION = "1.02"
3
3
  end
data/lib/sort_rank.rb CHANGED
@@ -1,10 +1,14 @@
1
1
  require "sort_rank/version"
2
2
 
3
- require "sort_rank/logic"
3
+ require "sort_rank/solver"
4
4
  # require 'mechanizer'
5
5
  # require 'scrub_db'
6
6
  require 'pry'
7
7
 
8
8
  module SortRank
9
- # Your code goes here...
9
+
10
+ def self.parse(args={})
11
+ result_hash = self::Solver.new.parse(args)
12
+ end
13
+
10
14
  end
data/sort_rank.gemspec CHANGED
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency 'scrub_db', '~> 2.23'
38
38
  spec.add_dependency 'url_verifier', '~> 2.12'
39
39
  spec.add_dependency 'utf8_sanitizer', '~> 2.16'
40
+ # spec.add_dependency 'wikipedia-client', '~> 1.5'
40
41
 
41
42
  # spec.add_dependency "activesupport-inflector", ['~> 0.1.0']
42
43
  spec.add_development_dependency 'bundler', '~> 1.16', '>= 1.16.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sort_rank
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.01'
4
+ version: '1.02'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Booth
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-05 00:00:00.000000000 Z
11
+ date: 2018-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -181,7 +181,7 @@ files:
181
181
  - bin/console
182
182
  - bin/setup
183
183
  - lib/sort_rank.rb
184
- - lib/sort_rank/logic.rb
184
+ - lib/sort_rank/solver.rb
185
185
  - lib/sort_rank/version.rb
186
186
  - sort_rank.gemspec
187
187
  homepage: https://github.com/4rlm/sort_rank
@@ -1,17 +0,0 @@
1
-
2
- module SortRank
3
- class Logic
4
-
5
- def initialize
6
- binding.pry
7
- end
8
-
9
- def start
10
- binding.pry
11
- "testing setup"
12
- end
13
-
14
-
15
-
16
- end
17
- end