nhkore 0.3.6 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +3 -0
- data/CHANGELOG.md +63 -2
- data/Gemfile +0 -18
- data/Gemfile.lock +89 -0
- data/README.md +36 -30
- data/Rakefile +38 -52
- data/bin/nhkore +4 -15
- data/lib/nhkore.rb +8 -20
- data/lib/nhkore/app.rb +236 -236
- data/lib/nhkore/article.rb +39 -53
- data/lib/nhkore/article_scraper.rb +301 -287
- 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 +89 -103
- 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 +75 -82
- data/lib/nhkore/search_link.rb +63 -75
- data/lib/nhkore/search_scraper.rb +89 -93
- 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 +105 -99
- data/nhkore.gemspec +54 -65
- data/samples/looper.rb +71 -0
- data/test/nhkore/test_helper.rb +3 -15
- data/test/nhkore_test.rb +6 -18
- metadata +50 -28
data/samples/looper.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
#--
|
6
|
+
# This file is part of NHKore.
|
7
|
+
# Copyright (c) 2020-2021 Jonathan Bradley Whited
|
8
|
+
#
|
9
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
10
|
+
#++
|
11
|
+
|
12
|
+
|
13
|
+
###
|
14
|
+
# If you run this script, be aware that it uses the +-F+ force option
|
15
|
+
# (which overwrites files without prompting).
|
16
|
+
#
|
17
|
+
# @author Jonathan Bradley Whited
|
18
|
+
# @since 0.3.2
|
19
|
+
###
|
20
|
+
|
21
|
+
case ARGV[0]
|
22
|
+
when '-c' # count
|
23
|
+
system('nhkore search ez --show-count')
|
24
|
+
puts
|
25
|
+
puts "Use the first number with the '-a' option."
|
26
|
+
exit
|
27
|
+
when '-a' # articles
|
28
|
+
articles = ARGV[1].to_i
|
29
|
+
articles = 0 if articles < 0
|
30
|
+
else
|
31
|
+
puts 'Options:'
|
32
|
+
puts ' -c show count to use with -a'
|
33
|
+
puts ' -a <int> number of articles already scraped; execute scraping'
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
|
37
|
+
articles_inc = 25
|
38
|
+
max_errors = 5 # Exit, for example, if 404 errors repeatedly
|
39
|
+
max_loop = 5 # Possible total = articles_inc * max_loop
|
40
|
+
|
41
|
+
thread = Thread.new do
|
42
|
+
i = 0
|
43
|
+
|
44
|
+
while i < max_loop
|
45
|
+
puts "Loop #{i += 1} => #{articles} articles"
|
46
|
+
|
47
|
+
if system("nhkore -F -t 300 -m 10 news ez -s #{articles_inc}")
|
48
|
+
articles += articles_inc
|
49
|
+
elsif (max_errors -= 1) <= 0
|
50
|
+
break
|
51
|
+
end
|
52
|
+
|
53
|
+
puts
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Ctrl+C
|
58
|
+
trap('INT') do
|
59
|
+
if thread.alive?
|
60
|
+
# Try to exit gracefully.
|
61
|
+
max_loop = -1
|
62
|
+
thread.join(5)
|
63
|
+
|
64
|
+
# Die!
|
65
|
+
thread.kill if thread.alive?
|
66
|
+
end
|
67
|
+
|
68
|
+
exit
|
69
|
+
end
|
70
|
+
|
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.10
|
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-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: attr_bool
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bimyou_segmenter
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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,14 +335,19 @@ 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: []
|
342
|
-
extra_rdoc_files:
|
342
|
+
extra_rdoc_files:
|
343
|
+
- CHANGELOG.md
|
344
|
+
- LICENSE.txt
|
345
|
+
- README.md
|
343
346
|
files:
|
347
|
+
- ".yardopts"
|
344
348
|
- CHANGELOG.md
|
345
349
|
- Gemfile
|
350
|
+
- Gemfile.lock
|
346
351
|
- LICENSE.txt
|
347
352
|
- README.md
|
348
353
|
- Rakefile
|
@@ -379,6 +384,7 @@ files:
|
|
379
384
|
- lib/nhkore/version.rb
|
380
385
|
- lib/nhkore/word.rb
|
381
386
|
- nhkore.gemspec
|
387
|
+
- samples/looper.rb
|
382
388
|
- test/nhkore/test_helper.rb
|
383
389
|
- test/nhkore_test.rb
|
384
390
|
- yard/templates/default/layout/html/footer.erb
|
@@ -386,22 +392,37 @@ homepage: https://github.com/esotericpig/nhkore
|
|
386
392
|
licenses:
|
387
393
|
- LGPL-3.0-or-later
|
388
394
|
metadata:
|
389
|
-
bug_tracker_uri: https://github.com/esotericpig/nhkore/issues
|
390
|
-
changelog_uri: https://github.com/esotericpig/nhkore/blob/master/CHANGELOG.md
|
391
395
|
homepage_uri: https://github.com/esotericpig/nhkore
|
392
396
|
source_code_uri: https://github.com/esotericpig/nhkore
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
397
|
+
bug_tracker_uri: https://github.com/esotericpig/nhkore/issues
|
398
|
+
changelog_uri: https://github.com/esotericpig/nhkore/blob/master/CHANGELOG.md
|
399
|
+
post_install_message: |2+
|
400
|
+
|
401
|
+
NHKore v0.3.10
|
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
|
+
|
412
|
+
rdoc_options:
|
413
|
+
- "--hyperlink-all"
|
414
|
+
- "--show-hash"
|
415
|
+
- "--title"
|
416
|
+
- NHKore v0.3.10 Doc
|
417
|
+
- "--main"
|
418
|
+
- README.md
|
398
419
|
require_paths:
|
399
420
|
- lib
|
400
421
|
required_ruby_version: !ruby/object:Gem::Requirement
|
401
422
|
requirements:
|
402
423
|
- - ">="
|
403
424
|
- !ruby/object:Gem::Version
|
404
|
-
version: '2.
|
425
|
+
version: '2.5'
|
405
426
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
406
427
|
requirements:
|
407
428
|
- - ">="
|
@@ -409,8 +430,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
409
430
|
version: '0'
|
410
431
|
requirements:
|
411
432
|
- 'Nokogiri: https://www.nokogiri.org/tutorials/installing_nokogiri.html'
|
412
|
-
rubygems_version: 3.
|
413
|
-
signing_key:
|
433
|
+
rubygems_version: 3.2.15
|
434
|
+
signing_key:
|
414
435
|
specification_version: 4
|
415
436
|
summary: NHK News Web (Easy) word frequency (core) scraper for Japanese language learners.
|
416
437
|
test_files: []
|
438
|
+
...
|