nhkore 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -2
- data/Gemfile +0 -18
- data/Gemfile.lock +32 -29
- data/README.md +19 -19
- data/Rakefile +38 -52
- data/bin/nhkore +4 -15
- data/lib/nhkore.rb +8 -20
- data/lib/nhkore/app.rb +229 -234
- data/lib/nhkore/article.rb +39 -53
- data/lib/nhkore/article_scraper.rb +293 -285
- data/lib/nhkore/cleaner.rb +20 -32
- data/lib/nhkore/cli/fx_cmd.rb +41 -53
- data/lib/nhkore/cli/get_cmd.rb +59 -70
- data/lib/nhkore/cli/news_cmd.rb +143 -153
- data/lib/nhkore/cli/search_cmd.rb +108 -118
- data/lib/nhkore/cli/sift_cmd.rb +109 -120
- data/lib/nhkore/datetime_parser.rb +88 -104
- data/lib/nhkore/defn.rb +48 -55
- data/lib/nhkore/dict.rb +26 -38
- data/lib/nhkore/dict_scraper.rb +31 -40
- data/lib/nhkore/entry.rb +43 -55
- data/lib/nhkore/error.rb +16 -21
- data/lib/nhkore/fileable.rb +10 -21
- data/lib/nhkore/lib.rb +5 -17
- data/lib/nhkore/missingno.rb +21 -33
- data/lib/nhkore/news.rb +58 -72
- data/lib/nhkore/polisher.rb +22 -34
- data/lib/nhkore/scraper.rb +74 -83
- data/lib/nhkore/search_link.rb +62 -76
- data/lib/nhkore/search_scraper.rb +81 -92
- data/lib/nhkore/sifter.rb +157 -171
- data/lib/nhkore/splitter.rb +19 -31
- data/lib/nhkore/user_agents.rb +28 -32
- data/lib/nhkore/util.rb +72 -84
- data/lib/nhkore/variator.rb +20 -32
- data/lib/nhkore/version.rb +4 -16
- data/lib/nhkore/word.rb +99 -97
- data/nhkore.gemspec +30 -51
- data/samples/looper.rb +18 -29
- data/test/nhkore/test_helper.rb +3 -15
- data/test/nhkore_test.rb +6 -18
- metadata +33 -24
data/samples/looper.rb
CHANGED
@@ -4,28 +4,17 @@
|
|
4
4
|
|
5
5
|
#--
|
6
6
|
# This file is part of NHKore.
|
7
|
-
# Copyright (c) 2020 Jonathan Bradley Whited
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# NHKore is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU Lesser General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU Lesser General Public License
|
20
|
-
# along with NHKore. If not, see <https://www.gnu.org/licenses/>.
|
7
|
+
# Copyright (c) 2020-2021 Jonathan Bradley Whited
|
8
|
+
#
|
9
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
21
10
|
#++
|
22
11
|
|
23
12
|
|
24
13
|
###
|
25
14
|
# If you run this script, be aware that it uses the +-F+ force option
|
26
15
|
# (which overwrites files without prompting).
|
27
|
-
#
|
28
|
-
# @author Jonathan Bradley Whited
|
16
|
+
#
|
17
|
+
# @author Jonathan Bradley Whited
|
29
18
|
# @since 0.3.2
|
30
19
|
###
|
31
20
|
|
@@ -33,10 +22,10 @@ case ARGV[0]
|
|
33
22
|
when '-c' # count
|
34
23
|
system('nhkore search ez --show-count')
|
35
24
|
puts
|
36
|
-
puts
|
25
|
+
puts "Use the first number with the '-a' option."
|
37
26
|
exit
|
38
27
|
when '-a' # articles
|
39
|
-
articles = ARGV[1].to_i
|
28
|
+
articles = ARGV[1].to_i
|
40
29
|
articles = 0 if articles < 0
|
41
30
|
else
|
42
31
|
puts 'Options:'
|
@@ -49,34 +38,34 @@ articles_inc = 25
|
|
49
38
|
max_errors = 5 # Exit, for example, if 404 errors repeatedly
|
50
39
|
max_loop = 5 # Possible total = articles_inc * max_loop
|
51
40
|
|
52
|
-
thread = Thread.new
|
41
|
+
thread = Thread.new do
|
53
42
|
i = 0
|
54
|
-
|
43
|
+
|
55
44
|
while i < max_loop
|
56
45
|
puts "Loop #{i += 1} => #{articles} articles"
|
57
|
-
|
46
|
+
|
58
47
|
if system("nhkore -F -t 300 -m 10 news ez -s #{articles_inc}")
|
59
48
|
articles += articles_inc
|
60
|
-
|
61
|
-
break
|
49
|
+
elsif (max_errors -= 1) <= 0
|
50
|
+
break
|
62
51
|
end
|
63
|
-
|
52
|
+
|
64
53
|
puts
|
65
54
|
end
|
66
55
|
end
|
67
56
|
|
68
57
|
# Ctrl+C
|
69
58
|
trap('INT') do
|
70
|
-
if thread.alive?
|
59
|
+
if thread.alive?
|
71
60
|
# Try to exit gracefully.
|
72
61
|
max_loop = -1
|
73
62
|
thread.join(5)
|
74
|
-
|
63
|
+
|
75
64
|
# Die!
|
76
|
-
thread.kill
|
65
|
+
thread.kill if thread.alive?
|
77
66
|
end
|
78
|
-
|
67
|
+
|
79
68
|
exit
|
80
69
|
end
|
81
70
|
|
82
|
-
thread.join
|
71
|
+
thread.join # Run
|
data/test/nhkore/test_helper.rb
CHANGED
@@ -1,23 +1,11 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# encoding: UTF-8
|
3
2
|
# frozen_string_literal: true
|
4
3
|
|
5
4
|
#--
|
6
5
|
# This file is part of NHKore.
|
7
|
-
# Copyright (c) 2020 Jonathan Bradley Whited
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# NHKore is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU Lesser General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU Lesser General Public License
|
20
|
-
# along with NHKore. If not, see <https://www.gnu.org/licenses/>.
|
6
|
+
# Copyright (c) 2020-2021 Jonathan Bradley Whited
|
7
|
+
#
|
8
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
21
9
|
#++
|
22
10
|
|
23
11
|
|
data/test/nhkore_test.rb
CHANGED
@@ -1,23 +1,11 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# encoding: UTF-8
|
3
2
|
# frozen_string_literal: true
|
4
3
|
|
5
4
|
#--
|
6
5
|
# This file is part of NHKore.
|
7
|
-
# Copyright (c) 2020 Jonathan Bradley Whited
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# NHKore is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU Lesser General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU Lesser General Public License
|
20
|
-
# along with NHKore. If not, see <https://www.gnu.org/licenses/>.
|
6
|
+
# Copyright (c) 2020-2021 Jonathan Bradley Whited
|
7
|
+
#
|
8
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
21
9
|
#++
|
22
10
|
|
23
11
|
|
@@ -26,10 +14,10 @@ require 'nhkore/test_helper'
|
|
26
14
|
|
27
15
|
module NHKore
|
28
16
|
class NHKoreTest < TestHelper
|
29
|
-
def setup
|
17
|
+
def setup
|
30
18
|
end
|
31
|
-
|
32
|
-
def test_something
|
19
|
+
|
20
|
+
def test_something
|
33
21
|
end
|
34
22
|
end
|
35
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nhkore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Jonathan Bradley Whited
|
8
|
-
autorequire:
|
7
|
+
- Jonathan Bradley Whited
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: attr_bool
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '5.
|
61
|
+
version: '5.2'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '5.
|
68
|
+
version: '5.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: highline
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '1.
|
117
|
+
version: '1.11'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '1.
|
124
|
+
version: '1.11'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: psychgus
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,14 +198,14 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: '0.
|
201
|
+
version: '0.18'
|
202
202
|
type: :runtime
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: '0.
|
208
|
+
version: '0.18'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: tty-spinner
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,14 +226,14 @@ dependencies:
|
|
226
226
|
requirements:
|
227
227
|
- - "~>"
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: '2.
|
229
|
+
version: '2.2'
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: '2.
|
236
|
+
version: '2.2'
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: minitest
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,14 +282,14 @@ dependencies:
|
|
282
282
|
requirements:
|
283
283
|
- - "~>"
|
284
284
|
- !ruby/object:Gem::Version
|
285
|
-
version: '6.
|
285
|
+
version: '6.3'
|
286
286
|
type: :development
|
287
287
|
prerelease: false
|
288
288
|
version_requirements: !ruby/object:Gem::Requirement
|
289
289
|
requirements:
|
290
290
|
- - "~>"
|
291
291
|
- !ruby/object:Gem::Version
|
292
|
-
version: '6.
|
292
|
+
version: '6.3'
|
293
293
|
- !ruby/object:Gem::Dependency
|
294
294
|
name: redcarpet
|
295
295
|
requirement: !ruby/object:Gem::Requirement
|
@@ -335,7 +335,7 @@ dependencies:
|
|
335
335
|
description: Scrapes NHK News Web (Easy) for the word frequency (core list) for Japanese
|
336
336
|
language learners. Includes a CLI app and a scraper library.
|
337
337
|
email:
|
338
|
-
-
|
338
|
+
- code@esotericpig.com
|
339
339
|
executables:
|
340
340
|
- nhkore
|
341
341
|
extensions: []
|
@@ -396,16 +396,24 @@ metadata:
|
|
396
396
|
source_code_uri: https://github.com/esotericpig/nhkore
|
397
397
|
bug_tracker_uri: https://github.com/esotericpig/nhkore/issues
|
398
398
|
changelog_uri: https://github.com/esotericpig/nhkore/blob/master/CHANGELOG.md
|
399
|
-
post_install_message:
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
399
|
+
post_install_message: |2+
|
400
|
+
|
401
|
+
NHKore v0.3.8
|
402
|
+
|
403
|
+
You can now use [nhkore] on the command line.
|
404
|
+
|
405
|
+
Homepage: https://github.com/esotericpig/nhkore
|
406
|
+
|
407
|
+
Code: https://github.com/esotericpig/nhkore
|
408
|
+
Bugs: https://github.com/esotericpig/nhkore/issues
|
409
|
+
|
410
|
+
Changelog: https://github.com/esotericpig/nhkore/blob/master/CHANGELOG.md
|
411
|
+
|
404
412
|
rdoc_options:
|
405
413
|
- "--hyperlink-all"
|
406
414
|
- "--show-hash"
|
407
415
|
- "--title"
|
408
|
-
- NHKore v0.3.
|
416
|
+
- NHKore v0.3.8 Doc
|
409
417
|
- "--main"
|
410
418
|
- README.md
|
411
419
|
require_paths:
|
@@ -414,7 +422,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
414
422
|
requirements:
|
415
423
|
- - ">="
|
416
424
|
- !ruby/object:Gem::Version
|
417
|
-
version: '2.
|
425
|
+
version: '2.5'
|
418
426
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
419
427
|
requirements:
|
420
428
|
- - ">="
|
@@ -422,8 +430,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
422
430
|
version: '0'
|
423
431
|
requirements:
|
424
432
|
- 'Nokogiri: https://www.nokogiri.org/tutorials/installing_nokogiri.html'
|
425
|
-
rubygems_version: 3.
|
426
|
-
signing_key:
|
433
|
+
rubygems_version: 3.2.15
|
434
|
+
signing_key:
|
427
435
|
specification_version: 4
|
428
436
|
summary: NHK News Web (Easy) word frequency (core) scraper for Japanese language learners.
|
429
437
|
test_files: []
|
438
|
+
...
|