tau_yandex_speller 0.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: edd2afb96580dba9bdc93799bc353d87faecb756
|
4
|
+
data.tar.gz: 4bad79e79b5e005b3d5810bb2d8379d8e810c864
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6de1e9d8621173609eb9332a6510fe2afb7f45b155922d69e7d43a58912995df6d2133b0cb26c9c2e90f9763fa32ced06f8a84d6a00155b085d9755c1144d5d8
|
7
|
+
data.tar.gz: c46ade2fb891dd1f28fe6a0d64f59e5d172983ef3405ae47c8f89b818ea1a8820fc7d40c11084ee9becc31d44e3550624fe622862e9e120a1a83bf42a636f5e7
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative './tau_yandex_speller/Controller/spell_checker'
|
2
|
+
require_relative './tau_yandex_speller/Model/spell'
|
3
|
+
|
4
|
+
module TauYandexSpeller
|
5
|
+
VERSION = '0.0.1'
|
6
|
+
|
7
|
+
def self.version
|
8
|
+
"ver. #{VERSION}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.check text
|
12
|
+
TauYandexSpeller::SpellChecker.check text
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
# p TauYandexSpeller::version
|
18
|
+
# sc = TauYandexSpeller::check "Малако, папв и прочия хна."
|
19
|
+
# sc.each do |e|
|
20
|
+
# p "word = #{e.word} words = #{e.correct_words} "
|
21
|
+
# end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative '../Manager/net_manager'
|
2
|
+
require_relative '../Model/spell'
|
3
|
+
require_relative '../../core_ext/object'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module TauYandexSpeller
|
7
|
+
|
8
|
+
class SpellChecker
|
9
|
+
|
10
|
+
def self.check text
|
11
|
+
json = TauYandexSpeller::NetManager.load_correct_words text
|
12
|
+
SpellCollection.new json
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'uri-handler'
|
3
|
+
|
4
|
+
module TauYandexSpeller
|
5
|
+
URL_API = "http://speller.yandex.net/services/spellservice.json/checkText?text="
|
6
|
+
|
7
|
+
class NetManager
|
8
|
+
|
9
|
+
def self.load_correct_words text
|
10
|
+
data_url = "#{URL_API}#{text.to_uri}"
|
11
|
+
data = ""
|
12
|
+
open(data_url.force_encoding('ASCII-8BIT')).each_line { |e| data += e }
|
13
|
+
data
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module TauYandexSpeller
|
4
|
+
|
5
|
+
class SpellCollection
|
6
|
+
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
attr_reader :spells
|
10
|
+
|
11
|
+
def each &block
|
12
|
+
@spells.each &block
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# asdad
|
19
|
+
def initialize json_data
|
20
|
+
@spells = parse!(json_data)
|
21
|
+
end
|
22
|
+
|
23
|
+
def parse! data
|
24
|
+
JSON.parse(data).map! do |record|
|
25
|
+
Spell.new record
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
class Spell
|
32
|
+
|
33
|
+
attr_reader :word, :correct_words
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def initialize record
|
38
|
+
# log "record #{record}"
|
39
|
+
@word = record["word"]
|
40
|
+
@correct_words = record["s"]
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tau_yandex_speller
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Torlopov Andyre
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: just homework
|
14
|
+
email: torlopov.andrey@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/core_ext/object.rb
|
20
|
+
- lib/tau_yandex_speller.rb
|
21
|
+
- lib/tau_yandex_speller/Controller/spell_checker.rb
|
22
|
+
- lib/tau_yandex_speller/Manager/net_manager.rb
|
23
|
+
- lib/tau_yandex_speller/Model/spell.rb
|
24
|
+
homepage: https://github.com/Torlopov-Andrey/ruby_course/tree/master/lesson_8/homework_8/tau_yandex_speller
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.5.1
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: This is an example, wich use yandex api for check words.
|
48
|
+
test_files: []
|