wikiquik 0.0.2
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 +7 -0
- data/bin/wikiquik +37 -0
- data/test/test_wikiquik.rb +16 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7ae6b6df073f8d98c1e6b43ebc39e74c01d29bca
|
4
|
+
data.tar.gz: 320a5a9d064c18cd2795f90950db6e22e06111d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6a0fb0815c2b7a0d5282fdcd48dbcefc88aabb8ff61bb95d2d3f224190993d430d91b375b29230babdca4d545bd027f223d2ffa5e82d7ba40e08f1bb79226d6
|
7
|
+
data.tar.gz: 46048779c53872cb97fb671206a2c19311abd509f7c135cc51f3c786a057e2e6d785fd463a194f759f5721ecb1e809d5807ead0b504506f63467cc0acc3d0fd3
|
data/bin/wikiquik
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'tactful_tokenizer'
|
6
|
+
require 'open-uri'
|
7
|
+
|
8
|
+
|
9
|
+
class Wikiquik
|
10
|
+
def self.wiki_search(search_term)
|
11
|
+
searcher = Wiki.new(search_term)
|
12
|
+
searcher.wiki_search
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
class Wiki
|
18
|
+
def initialize(user_input_term)
|
19
|
+
@term = user_input_term.split(" ").map(&:capitalize).join("+")
|
20
|
+
page = open "https://www.google.com/search?q=wikipedia:#{@term}"
|
21
|
+
search_result = Nokogiri::HTML page
|
22
|
+
wiki_page = search_result.search("cite")[0].inner_text
|
23
|
+
@wiki = open "http://#{wiki_page}"
|
24
|
+
@wikipedia = Nokogiri::HTML @wiki
|
25
|
+
end
|
26
|
+
|
27
|
+
def wiki_search
|
28
|
+
m = TactfulTokenizer::Model.new
|
29
|
+
m.tokenize_text(@wikipedia.css('p')[0].text)[0..1].join(" ")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
puts "-------------------------------"
|
34
|
+
puts "Wikiquik"
|
35
|
+
puts "What would you like to define?"
|
36
|
+
user_input = gets.chomp
|
37
|
+
puts Wikiquik.wiki_search(user_input)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# require 'test/unit'
|
2
|
+
# require 'wikiquik'
|
3
|
+
|
4
|
+
# # class WikiTest < Test::Unit::TestCase
|
5
|
+
# # def test_english_hello
|
6
|
+
# assert_equal "hello world", Hola.hi("english")
|
7
|
+
# end
|
8
|
+
|
9
|
+
# def test_any_hello
|
10
|
+
# assert_equal "hello world", Hola.hi("ruby")
|
11
|
+
# end
|
12
|
+
|
13
|
+
# def test_spanish_hello
|
14
|
+
# assert_equal "hola mundo", Hola.hi("spanish")
|
15
|
+
# end
|
16
|
+
# end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wikiquik
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dave Kerr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A ruby gem that will return the wikipedia definition of a term to the
|
14
|
+
console
|
15
|
+
email: davek09@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/wikiquik
|
21
|
+
- test/test_wikiquik.rb
|
22
|
+
homepage: http://rubygems.org/gems/wikiquik
|
23
|
+
licenses: []
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.2.1
|
42
|
+
signing_key:
|
43
|
+
specification_version: 3
|
44
|
+
summary: Quick Wikipedia Definitions!
|
45
|
+
test_files:
|
46
|
+
- test/test_wikiquik.rb
|