sosowa 0.6 → 0.7
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.
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -0
- data/README.md +2 -0
- data/Rakefile +6 -0
- data/lib/sosowa/scheme.rb +5 -1
- data/lib/sosowa/version.rb +1 -1
- data/samples/token_segment.rb +2 -2
- data/spec/sosowa_spec.rb +42 -0
- data/spec/spec_helper.rb +8 -0
- metadata +23 -7
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/sosowa/scheme.rb
CHANGED
@@ -34,7 +34,11 @@ module Sosowa
|
|
34
34
|
@page = @agent.get(URI.join(Sosowa::BASE_URL, params))
|
35
35
|
title = (@page/%{div[@class="header"] > h1})[0].inner_html.to_s.toutf8.strip
|
36
36
|
tags = (@page/%{dl[@class="info"][1] > dd > a}).map{|t| t.inner_html.to_s.toutf8 }
|
37
|
-
text =
|
37
|
+
text = ""
|
38
|
+
text_node = @page/%{div[@class="contents ss"]}
|
39
|
+
text_node.children.each do |node|
|
40
|
+
text += node.inner_html.to_s.toutf8.strip
|
41
|
+
end
|
38
42
|
aft = @page/%{div[@class="aft"]}
|
39
43
|
ps = (aft.size > 0) ? aft[0].inner_html.to_s.toutf8 : ""
|
40
44
|
author_name = (@page/%{div[@class="author"] b})[0].inner_html.to_s.toutf8
|
data/lib/sosowa/version.rb
CHANGED
data/samples/token_segment.rb
CHANGED
@@ -10,9 +10,9 @@ puts "Fetching thdic-mecab..."
|
|
10
10
|
system("curl -L https://github.com/oame/thdic-mecab/raw/master/pkg/thdic-mecab.dic > thdic-mecab.dic") unless FileTest.exists? "thdic-mecab.dic"
|
11
11
|
|
12
12
|
puts "Done. Initialize MeCab::Tagger"
|
13
|
-
mecab = MeCab::Tagger.new("-u thdic-mecab.dic")
|
13
|
+
mecab = MeCab::Tagger.new#("-u thdic-mecab.dic")
|
14
14
|
|
15
|
-
text = Sosowa.get.sample.fetch.
|
15
|
+
text = Sosowa.get.sample.fetch.plain
|
16
16
|
tokens = mecab.parseToNode(text)
|
17
17
|
tokens.each do |token|
|
18
18
|
puts token.feature
|
data/spec/sosowa_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require "pp"
|
4
|
+
require "spec_helper"
|
5
|
+
|
6
|
+
describe Sosowa, "が #get, :log => 0 を呼ぶ時は" do
|
7
|
+
before do
|
8
|
+
@log = Sosowa.get :log => 0
|
9
|
+
end
|
10
|
+
|
11
|
+
it "Sosowa::Logを返すこと" do
|
12
|
+
@log.class.should == Sosowa::Log
|
13
|
+
end
|
14
|
+
|
15
|
+
it "最初がSosowa::Indexであること" do
|
16
|
+
@log.first.class.should == Sosowa::Index
|
17
|
+
end
|
18
|
+
|
19
|
+
it "最初のタイトルがStringであること" do
|
20
|
+
@log.first.title.class.should == String
|
21
|
+
end
|
22
|
+
|
23
|
+
it "#next_pageがSosowa::Logを返すこと" do
|
24
|
+
@log.next_page.class.should == Sosowa::Log
|
25
|
+
end
|
26
|
+
|
27
|
+
it "#prev_pageがSosowa::Logを返すこと" do
|
28
|
+
@log.prev_page.class.should == Sosowa::Log
|
29
|
+
end
|
30
|
+
|
31
|
+
it "#latest_logがFixnumを返すこと" do
|
32
|
+
@log.latest_log.class.should == Fixnum
|
33
|
+
end
|
34
|
+
|
35
|
+
it "最初を#fetchしたらSosowa::Novelを返すこと" do
|
36
|
+
@log.first.fetch.class.should == Sosowa::Novel
|
37
|
+
end
|
38
|
+
|
39
|
+
it "最初を#fetchしたSosowa::Novel#titleがStringなこと" do
|
40
|
+
@log.first.fetch.title.class.should == String
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
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.7'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
description: Sosowa Parser for Ruby
|
26
31
|
email:
|
27
32
|
- oame@oameya.com
|
@@ -30,6 +35,8 @@ extensions: []
|
|
30
35
|
extra_rdoc_files: []
|
31
36
|
files:
|
32
37
|
- .gitignore
|
38
|
+
- .rspec
|
39
|
+
- .travis.yml
|
33
40
|
- CHANGELOG.md
|
34
41
|
- Gemfile
|
35
42
|
- LICENSE
|
@@ -45,6 +52,8 @@ files:
|
|
45
52
|
- samples/tf-idf.rb
|
46
53
|
- samples/token_segment.rb
|
47
54
|
- sosowa.gemspec
|
55
|
+
- spec/sosowa_spec.rb
|
56
|
+
- spec/spec_helper.rb
|
48
57
|
homepage: ''
|
49
58
|
licenses: []
|
50
59
|
post_install_message:
|
@@ -57,17 +66,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
66
|
- - ! '>='
|
58
67
|
- !ruby/object:Gem::Version
|
59
68
|
version: '0'
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
hash: -181387724163016397
|
60
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
73
|
none: false
|
62
74
|
requirements:
|
63
75
|
- - ! '>='
|
64
76
|
- !ruby/object:Gem::Version
|
65
77
|
version: '0'
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
hash: -181387724163016397
|
66
81
|
requirements: []
|
67
82
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.8.
|
83
|
+
rubygems_version: 1.8.24
|
69
84
|
signing_key:
|
70
85
|
specification_version: 3
|
71
86
|
summary: Sosowa Parser for Ruby 1.9.x.
|
72
|
-
test_files:
|
73
|
-
|
87
|
+
test_files:
|
88
|
+
- spec/sosowa_spec.rb
|
89
|
+
- spec/spec_helper.rb
|