rtatoeba 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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +16 -0
- data/README.md +53 -0
- data/Rakefile +1 -0
- data/lib/rtatoeba.rb +49 -0
- data/lib/rtatoeba/version.rb +3 -0
- data/rtatoeba.gemspec +24 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0832f6e79898d9bb0aba8e84a280579713f53e00
|
4
|
+
data.tar.gz: 95659523a21c1855740ecd49870e3b4f3d6c04d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80d5f400480c218107a4cde14a8438e51fab3a57a3743800d3dd22a1acc006b86b99b7490507579a31b0582b12fc150cc1e69feddd4088c2aae8bb724dce765a
|
7
|
+
data.tar.gz: d95d9bfe12b149ad3af12a31c6707bfab51dfe97e646eb716837c13174321de011f604ffe08ced5c47901eba46e15790d35aaeab0989abe57131c2dfd66f9611
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#
|
2
|
+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
3
|
+
# Version 2, December 2004
|
4
|
+
#
|
5
|
+
# Copyright (C) 2004 Sam Hocevar
|
6
|
+
# 14 rue de Plaisance, 75014 Paris, France
|
7
|
+
# Everyone is permitted to copy and distribute verbatim or modified
|
8
|
+
# copies of this license document, and changing it is allowed as long
|
9
|
+
# as the name is changed.
|
10
|
+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
11
|
+
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
12
|
+
# 0. You just DO WHAT THE FUCK YOU WANT TO.
|
13
|
+
#
|
14
|
+
#
|
15
|
+
# David Hagege <david.hagege@gmail.com>
|
16
|
+
#
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Rtatoeba
|
2
|
+
|
3
|
+
Rtatoeba is a tiny gem to access tatoeba.org which doesn't have an API yet.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rtatoeba'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rtatoeba
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
tatoe = Rtatoeba::Rtatoeba.new(from: 'eng', to: 'kor', query: 'hello')
|
22
|
+
tatoe.sentences # =>
|
23
|
+
{
|
24
|
+
"Hello, I have a reservation, my name is Kaori Yoshikawa. Here is the confirmation card." => [
|
25
|
+
[0] "안녕하세요,예약을 했는데요, 제이름은 카오리 요시카와 입니다. 확인카드는 여기있습니다."
|
26
|
+
],
|
27
|
+
"Hello, Tom." => [
|
28
|
+
[0] "안녕, 톰."
|
29
|
+
],
|
30
|
+
"Hello, I am Nancy." => [
|
31
|
+
[0] "안녕하세요. 난시입니다.",
|
32
|
+
[1] "안녕하세요, 저는 낸시예요."
|
33
|
+
],
|
34
|
+
"Hello!" => [
|
35
|
+
[0] "안녕하세요.",
|
36
|
+
[1] "여보세요."
|
37
|
+
],
|
38
|
+
"Hello, it's me, Nancy!" => [
|
39
|
+
[0] "안녕하세요. 난시입니다."
|
40
|
+
],
|
41
|
+
"Hello world!" => [
|
42
|
+
[0] "안녕하세요세계"
|
43
|
+
]
|
44
|
+
}
|
45
|
+
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/rtatoeba.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
#
|
3
|
+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
4
|
+
# Version 2, December 2004
|
5
|
+
#
|
6
|
+
# Copyright (C) 2004 Sam Hocevar
|
7
|
+
# 14 rue de Plaisance, 75014 Paris, France
|
8
|
+
# Everyone is permitted to copy and distribute verbatim or modified
|
9
|
+
# copies of this license document, and changing it is allowed as long
|
10
|
+
# as the name is changed.
|
11
|
+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
12
|
+
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
13
|
+
# 0. You just DO WHAT THE FUCK YOU WANT TO.
|
14
|
+
#
|
15
|
+
#
|
16
|
+
# David Hagege <david.hagege@gmail.com>
|
17
|
+
#
|
18
|
+
|
19
|
+
require "rtatoeba/version"
|
20
|
+
require 'mechanize'
|
21
|
+
|
22
|
+
module Rtatoeba
|
23
|
+
class Rtatoeba
|
24
|
+
def initialize(params={})
|
25
|
+
@from = params[:from] || "eng"
|
26
|
+
@to = params[:to] || "eng"
|
27
|
+
@query = params[:query]
|
28
|
+
|
29
|
+
@agent = Mechanize.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def sentences
|
33
|
+
content =
|
34
|
+
@agent.get("http://tatoeba.org/eng/sentences/search?query=#{@query}&from=#{@from}&to=#{@to}")
|
35
|
+
sentences = {}
|
36
|
+
mainSentence = ''
|
37
|
+
content.links_with(:href => /eng\/sentences\/show/,
|
38
|
+
:dom_class => /text/).map do |s|
|
39
|
+
if s.node.parent.parent['class'] =~ /mainSentence/
|
40
|
+
sentences[s.text] ||= []
|
41
|
+
mainSentence = s.text
|
42
|
+
else
|
43
|
+
(sentences[mainSentence] ||= []) << s.text
|
44
|
+
end
|
45
|
+
end
|
46
|
+
sentences
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/rtatoeba.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rtatoeba/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rtatoeba"
|
8
|
+
spec.version = Rtatoeba::VERSION
|
9
|
+
spec.authors = ["David Hagege"]
|
10
|
+
spec.email = ["david.hagege@gmail.com"]
|
11
|
+
spec.description = %q{Tiny gem to get sample sentences from tatoeba.org}
|
12
|
+
spec.summary = %q{}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "WTFPL"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "mechanize"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rtatoeba
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Hagege
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mechanize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Tiny gem to get sample sentences from tatoeba.org
|
56
|
+
email:
|
57
|
+
- david.hagege@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/rtatoeba.rb
|
68
|
+
- lib/rtatoeba/version.rb
|
69
|
+
- rtatoeba.gemspec
|
70
|
+
homepage: ''
|
71
|
+
licenses:
|
72
|
+
- WTFPL
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.0.3
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: ''
|
94
|
+
test_files: []
|