asiasearch 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.
Files changed (3) hide show
  1. data/README.mkdn +18 -0
  2. data/lib/asiasearch.rb +44 -0
  3. metadata +110 -0
data/README.mkdn ADDED
@@ -0,0 +1,18 @@
1
+ Yahoo Asia Search a.k.a Yahoo!搜尋『斷章取義』
2
+ ========
3
+
4
+ Description
5
+ ------------------
6
+ Yahoo Asia Search provides user an interface for automated semantic analysis and language treatment.
7
+
8
+ You must [register first](http://developer.yahoo.com/wsregapp/index.php) to get API key.
9
+ Then [activate it](http://asia.search.yahooapis.com/cas/v1/AuthBootUp.php?appid=APIKEY).
10
+
11
+ You can get more detail on [Officical Site] (http://tw.developer.yahoo.com/cas/api.php).
12
+
13
+ Author
14
+ ------------------
15
+
16
+ Author: xdite (xuite.joke@gmail.com)
17
+
18
+ Blog: http://blog.xdite.net
data/lib/asiasearch.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'rubygems'
2
+ require 'hpricot'
3
+ require 'mechanize'
4
+ require 'json'
5
+
6
+ class AsiaSearch
7
+ attr_reader :appid, :content, :threshold, :maxnum
8
+ def initialize
9
+ @paths = {
10
+ :ke => "http://asia.search.yahooapis.com/cas/v1/ke",
11
+ :ws => "http://asia.search.yahooapis.com/cas/v1/ws",
12
+ }
13
+ end
14
+
15
+ def ws(appid, content)
16
+ agent = WWW::Mechanize.new
17
+ params = {
18
+ :appid => appid,
19
+ :content => content,
20
+ :format => "json"
21
+ }
22
+
23
+ agent.post(@paths[:ws],params)
24
+ data = agent.current_page.body
25
+ result = JSON.parse(data)
26
+ return result
27
+ end
28
+
29
+ def ke(appid,content,threshold=30,maxnum=10)
30
+ agent = WWW::Mechanize.new
31
+ params = {
32
+ :appid => appid,
33
+ :content => content,
34
+ :threshold => threshold,
35
+ :maxnum => maxnum,
36
+ :format => "json"
37
+ }
38
+
39
+ agent.post(@paths[:ke],params)
40
+ data = agent.current_page.body
41
+ result = JSON.parse(data)
42
+ return result
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asiasearch
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Yi-Ting Cheng
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2009-02-06 00:00:00 +08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: hpricot
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: json_pure
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: mechanize
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ description: Yahoo Asia Search provides user an interface for automated semantic analysis and language treatment.
64
+ email:
65
+ - xuite.joke@gmail.com
66
+ executables: []
67
+
68
+ extensions: []
69
+
70
+ extra_rdoc_files: []
71
+
72
+ files:
73
+ - lib/asiasearch.rb
74
+ - README.mkdn
75
+ has_rdoc: true
76
+ homepage: https://github.com/xdite/asiasearch
77
+ licenses: []
78
+
79
+ post_install_message:
80
+ rdoc_options: []
81
+
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ requirements: []
103
+
104
+ rubyforge_project:
105
+ rubygems_version: 1.5.2
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Yahoo Asia Search provides user an interface for automated semantic analysis and language treatment.
109
+ test_files: []
110
+