speller_yandex 1.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bdef48d478a1d9d60e05c58b27487866026c6f9f
4
+ data.tar.gz: be2a87c25f5191b1330454a4c89f476995e911c7
5
+ SHA512:
6
+ metadata.gz: 2b2d48621560bed42faf865fe61c67b6c8b725218dc9d4a60fb270d7d2a3a8bd645ea4c76754bd622c4f9d8fc56a668fc6fc17e3235f722d8bcc6f7ce73942a7
7
+ data.tar.gz: 23460120d62ae8897d75123b4d508fcafec36ebca012abc9ac3e9cc75e71674ddd15cfedc0216f99fcda2494a0a56ce5e01f37b6356747ff361e454667f2094d
@@ -0,0 +1,12 @@
1
+ module SpellerYandex
2
+ module Data
3
+
4
+ DATA_URL = "http://speller.yandex.net/services/spellservice.json/checkText?text="
5
+
6
+ def self.import text
7
+ data_url_acii = URI.encode(DATA_URL + text)
8
+ wrong_words = open data_url_acii
9
+ wrong_words.read
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ module SpellerYandex
2
+ class Main
3
+
4
+ def self.parse text, wrong_words
5
+ array = JSON.parse wrong_words
6
+ array.each do |hash|
7
+ word = hash["word"]
8
+ s = hash["s"].join
9
+ text = text.gsub(word, s)
10
+ end
11
+ text
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ require 'json'
2
+ require 'open-uri'
3
+ require_relative 'speller_yandex/main'
4
+ require_relative 'speller_yandex/data'
5
+
6
+ module SpellerYandex
7
+
8
+ def self.check text
9
+ wrong_words = Data.import text
10
+ corrected_text = Main.parse text, wrong_words
11
+ puts corrected_text
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: speller_yandex
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexey Spiridonov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Use SpellerYandex.check "..." method to correct text
14
+ email: alex9spiridonov@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/speller_yandex.rb
20
+ - lib/speller_yandex/data.rb
21
+ - lib/speller_yandex/main.rb
22
+ homepage: http://rubygems.org/gems/speller_yandex
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements:
41
+ - Internet connection,
42
+ - A good mood
43
+ rubyforge_project:
44
+ rubygems_version: 2.4.6
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Text correction
48
+ test_files: []