sosowa 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -5
- data/lib/sosowa/parser.rb +6 -1
- data/lib/sosowa/scheme.rb +10 -2
- data/lib/sosowa/version.rb +1 -1
- data/samples/feature-0.5.rb +13 -0
- metadata +4 -3
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,19 @@
|
|
1
|
+
## 0.5
|
2
|
+
* Sosowa::LogをArrayを継承したクラスに変更。Log.size等使えるようになりました
|
3
|
+
* Sosowa::Log#latest_logを追加
|
4
|
+
* 0.5のサンプルはsamples/feature-0.5.rbで確認することが出来ます。
|
5
|
+
|
1
6
|
## 0.4
|
2
7
|
* 細かいバグを修正
|
3
8
|
|
4
9
|
## 0.3
|
5
|
-
* Sosowa
|
6
|
-
* Sosowa#
|
7
|
-
* Sosowa#
|
8
|
-
* 0.3のサンプルは
|
10
|
+
* Sosowa::Logを追加。作品集単位で抽象化出来るようになりました。殆どの場合、このクラスはArrayとして振る舞います。
|
11
|
+
* Sosowa::Log#logで絶対作品集番号を得ることが出来ます。このメソッドは最新作品集であっても0では無く実際の番号が割り振られます。
|
12
|
+
* Sosowa::Log#next_page, Sosowa::Log#prev_pageが追加されました。前後のページを取得してSosowa#Logを返します。
|
13
|
+
* 0.3のサンプルはsamples/feature-0.3.rbで確認することが出来ます。
|
9
14
|
|
10
15
|
## 0.2
|
11
|
-
* Sosowa::Novel
|
16
|
+
* Sosowa::Novel#titleを追加。むしろどうして今まで無かった
|
12
17
|
* Sosowa::Author, Sosowa::Commentが取得出来ないバグを修正
|
13
18
|
|
14
19
|
## 0.1
|
data/lib/sosowa/parser.rb
CHANGED
@@ -18,7 +18,7 @@ module Sosowa
|
|
18
18
|
page = @agent.get(URI.join(Sosowa::BASE_URL, params))
|
19
19
|
indexes = parse_index(page)
|
20
20
|
abs_log_num = parse_absolute_log_number(page)
|
21
|
-
Log.new(indexes, abs_log_num)
|
21
|
+
Log.new(indexes, page, abs_log_num)
|
22
22
|
end
|
23
23
|
|
24
24
|
def parse_absolute_log_number(page)
|
@@ -32,6 +32,11 @@ module Sosowa
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def parse_latest_log_number(page)
|
36
|
+
li = page.search(%{ul[@id="pages"] li > *})
|
37
|
+
return li.size
|
38
|
+
end
|
39
|
+
|
35
40
|
def parse_index(page)
|
36
41
|
indexes = []
|
37
42
|
tr = page.search("tr")
|
data/lib/sosowa/scheme.rb
CHANGED
@@ -113,11 +113,14 @@ module Sosowa
|
|
113
113
|
alias_method :get, :fetch
|
114
114
|
end
|
115
115
|
|
116
|
-
class Log <
|
116
|
+
class Log < Array
|
117
|
+
attr_reader :element
|
117
118
|
attr_reader :log
|
118
119
|
|
119
|
-
def initialize(element, log=0)
|
120
|
+
def initialize(element, page, log=0)
|
120
121
|
super(element)
|
122
|
+
@element = element
|
123
|
+
@page = page
|
121
124
|
@log = log
|
122
125
|
end
|
123
126
|
|
@@ -132,5 +135,10 @@ module Sosowa
|
|
132
135
|
parser.fetch_index(@log+1)
|
133
136
|
end
|
134
137
|
alias_method :prev, :prev_page
|
138
|
+
|
139
|
+
def latest_log
|
140
|
+
parser = Parser.new
|
141
|
+
parser.parse_latest_log_number(@page)
|
142
|
+
end
|
135
143
|
end
|
136
144
|
end
|
data/lib/sosowa/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sosowa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-07-22 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
16
|
-
requirement: &
|
16
|
+
requirement: &70250654256620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70250654256620
|
25
25
|
description: Sosowa Parser for Ruby
|
26
26
|
email:
|
27
27
|
- oame@oameya.com
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- lib/sosowa/version.rb
|
42
42
|
- samples/chara_recognize.rb
|
43
43
|
- samples/feature-0.3.rb
|
44
|
+
- samples/feature-0.5.rb
|
44
45
|
- samples/tf-idf.rb
|
45
46
|
- samples/token_segment.rb
|
46
47
|
- sosowa.gemspec
|