nhkore 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4341573213802220b2346cc1f4b413c6749e260cd175321720da5c9c255df5de
4
+ data.tar.gz: c521924378f5bd723b9a19fcb80322a9b038ebeb4a696cd0a5b141bdf3cc9e17
5
+ SHA512:
6
+ metadata.gz: 890109ade84eeb406bf74e0bb101e79bded018d3d1988587911600a95782c010686932b9206f08413f7502168b86a867cbea1724fd0dd9b5134dd139a642e440
7
+ data.tar.gz: dc82cb006343c13e87011bf5408575df4f4a8e4c84b70d7cbe1db1a240248188fa1b9861c7634d6d6220b4f24c41c471ee341cf7cc76a40ef90b4df84f8e0522
@@ -0,0 +1,23 @@
1
+ # Changelog | NHKore
2
+
3
+ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
+
5
+ ## [[Unreleased]](https://github.com/esotericpig/nhkore/compare/v0.1.1...master)
6
+
7
+ ## [v0.1.0] - 2020-02-24
8
+ ### Added
9
+ - .gitignore
10
+ - CHANGELOG.md
11
+ - Gemfile
12
+ - LICENSE.txt
13
+ - nhkore.gemspec
14
+ - Rakefile
15
+ - README.md
16
+ - TODO.md
17
+ - bin/nhkore
18
+ - lib/nhkore.rb
19
+ - lib/nhkore/version.rb
20
+ - lib/nhkore/word.rb
21
+ - test/nhkore_test.rb
22
+ - test/nhkore_tester.rb
23
+ - yard/templates/default/layout/html/footer.erb
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ #--
5
+ # This file is part of NHKore.
6
+ # Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
7
+ #
8
+ # NHKore is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU Lesser General Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # NHKore is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public License
19
+ # along with NHKore. If not, see <https://www.gnu.org/licenses/>.
20
+ #++
21
+
22
+
23
+ source 'https://rubygems.org'
24
+
25
+ gemspec
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,69 @@
1
+ # NHKore
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/nhkore.svg)](https://badge.fury.io/rb/nhkore)
4
+
5
+ [![Source Code](https://img.shields.io/badge/source-github-%23A0522D.svg?style=for-the-badge)](https://github.com/esotericpig/nhkore)
6
+ [![Changelog](https://img.shields.io/badge/changelog-md-%23A0522D.svg?style=for-the-badge)](CHANGELOG.md)
7
+ [![License](https://img.shields.io/github/license/esotericpig/nhkore.svg?color=%23A0522D&style=for-the-badge)](LICENSE.txt)
8
+
9
+ A CLI app that scrapes [NHK News Web Easy](https://www3.nhk.or.jp/news/easy/) to create a list of each word and its frequency (how many times it was used) for Japanese language learners.
10
+
11
+ This is similar to a [core word/vocabulary list](https://www.fluentin3months.com/core-japanese-words/), hence the name NHKore.
12
+
13
+ In the future, I would like to add the regular NHK News, using the links from the easy versions.
14
+
15
+ ## Contents
16
+
17
+ - [Installing](#installing)
18
+ - [Using](#using)
19
+ - [Hacking](#hacking)
20
+ - [License](#license)
21
+
22
+ ## [Installing](#contents)
23
+
24
+ Pick your poison...
25
+
26
+ With the RubyGems CLI package manager:
27
+
28
+ `$ gem install nhkore`
29
+
30
+ Manually:
31
+
32
+ ```
33
+ $ git clone 'https://github.com/esotericpig/nhkore.git'
34
+ $ cd nhkore
35
+ $ bundle install
36
+ $ bundle exec rake install:local
37
+ ```
38
+
39
+ ## [Using](#contents)
40
+
41
+ TODO: using...
42
+
43
+ ## [Hacking](#contents)
44
+
45
+ ```
46
+ $ git clone 'https://github.com/esotericpig/nhkore.git'
47
+ $ bundle install
48
+ $ bundle exec rake -T
49
+ ```
50
+
51
+ ## [License](#contents)
52
+
53
+ [GNU LGPL v3+](LICENSE.txt)
54
+
55
+ > NHKore (<https://github.com/esotericpig/nhkore>)
56
+ > Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
57
+ >
58
+ > NHKore is free software: you can redistribute it and/or modify
59
+ > it under the terms of the GNU Lesser General Public License as published by
60
+ > the Free Software Foundation, either version 3 of the License, or
61
+ > (at your option) any later version.
62
+ >
63
+ > NHKore is distributed in the hope that it will be useful,
64
+ > but WITHOUT ANY WARRANTY; without even the implied warranty of
65
+ > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66
+ > GNU Lesser General Public License for more details.
67
+ >
68
+ > You should have received a copy of the GNU Lesser General Public License
69
+ > along with NHKore. If not, see <https://www.gnu.org/licenses/>.
@@ -0,0 +1,108 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ #--
5
+ # This file is part of NHKore.
6
+ # Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
7
+ #
8
+ # NHKore is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU Lesser General Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # NHKore is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public License
19
+ # along with NHKore. If not, see <https://www.gnu.org/licenses/>.
20
+ #++
21
+
22
+
23
+ require 'bundler/gem_tasks'
24
+
25
+ require 'nhkore/version'
26
+ require 'rake/clean'
27
+ require 'rake/testtask'
28
+ require 'raketeer/irb'
29
+ require 'raketeer/nokogiri_installs'
30
+ require 'raketeer/run'
31
+ require 'yard'
32
+ require 'yard_ghurt'
33
+
34
+
35
+ CORE_DIR = 'core'
36
+ PKG_DIR = 'pkg'
37
+
38
+ CLEAN.exclude('.git/','stock/',File.join(CORE_DIR,''))
39
+ CLOBBER.include('doc/',File.join(PKG_DIR,''))
40
+
41
+
42
+ task default: [:test]
43
+
44
+ desc 'Generate documentation (YARDoc)'
45
+ task :doc => [:yard,:yard_gfm_fix] do |task|
46
+ end
47
+
48
+ desc "Package '#{File.join(CORE_DIR,'')}' data as a Zip file into '#{File.join(PKG_DIR,'')}'"
49
+ task :pkg_core do |task|
50
+ pattern = File.join(CORE_DIR,'**','*.{csv,yml}')
51
+ zip_name = "nhkore-core-#{NHKore::VERSION}.zip"
52
+ zip_file = File.join(PKG_DIR,zip_name)
53
+
54
+ mkdir_p PKG_DIR
55
+
56
+ Dir.glob(pattern).sort().each() do |file|
57
+ # Rake::PackageTask does the same thing
58
+ sh 'zip','-8','-r',zip_file,file
59
+ end
60
+ end
61
+
62
+ Rake::TestTask.new() do |task|
63
+ task.libs = ['lib','test']
64
+ task.pattern = File.join('test','**','*_test.rb')
65
+ task.description += ": '#{task.pattern}'"
66
+ task.verbose = true
67
+ task.warning = true
68
+ end
69
+
70
+ YARD::Rake::YardocTask.new() do |task|
71
+ task.files = [File.join('lib','**','*.rb')]
72
+
73
+ task.options += ['--files','CHANGELOG.md,LICENSE.txt']
74
+ task.options += ['--readme','README.md']
75
+
76
+ task.options << '--protected' # Show protected methods
77
+ task.options += ['--template-path',File.join('yard','templates')]
78
+ task.options += ['--title',"NHKore v#{NHKore::VERSION} Doc"]
79
+ end
80
+
81
+ # Execute "yard_gfm_fix" for production.
82
+ # Execute "yard_gfm_fix[true]" for testing locally.
83
+ YardGhurt::GFMFixTask.new() do |task|
84
+ task.arg_names = [:dev]
85
+ task.dry_run = false
86
+ task.fix_code_langs = true
87
+ task.md_files = ['index.html']
88
+
89
+ task.before = Proc.new() do |task,args|
90
+ # Delete this file as it's never used (index.html is an exact copy)
91
+ YardGhurt::Util.rm_exist(File.join(task.doc_dir,'file.README.html'))
92
+
93
+ # Root dir of my GitHub Page for CSS/JS
94
+ GHP_ROOT = YardGhurt::Util.to_bool(args.dev) ? '../../esotericpig.github.io' : '../../..'
95
+
96
+ task.css_styles << %Q(<link rel="stylesheet" type="text/css" href="#{GHP_ROOT}/css/prism.css" />)
97
+ task.js_scripts << %Q(<script src="#{GHP_ROOT}/js/prism.js"></script>)
98
+ end
99
+ end
100
+
101
+ # Execute "rake yard_ghp_sync" for a dry run.
102
+ # Execute "rake yard_ghp_sync[true]" for actually deploying.
103
+ YardGhurt::GHPSyncTask.new() do |task|
104
+ task.description = %q(Rsync "doc/" to my GitHub Page's repo; not useful for others)
105
+
106
+ task.ghp_dir = '../esotericpig.github.io/docs/nhkore/yardoc'
107
+ task.sync_args << '--delete-after'
108
+ end
@@ -0,0 +1,29 @@
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 Jonathan Bradley Whited (@esotericpig)
8
+ #
9
+ # NHKore is free software: you can redistribute it and/or modify
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/>.
21
+ #++
22
+
23
+
24
+ require 'nhkore'
25
+
26
+
27
+ #app = NHKore::App.new()
28
+
29
+ #app.run()
@@ -0,0 +1,80 @@
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 Jonathan Bradley Whited (@esotericpig)
8
+ #
9
+ # NHKore is free software: you can redistribute it and/or modify
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/>.
21
+ #++
22
+
23
+
24
+ IS_TESTING = ($0 == __FILE__)
25
+
26
+ if IS_TESTING
27
+ require 'rubygems'
28
+ require 'bundler/setup'
29
+ end
30
+
31
+ require 'nhkore/version'
32
+ require 'nhkore/word'
33
+
34
+
35
+ require 'nokogiri'
36
+ require 'psychgus'
37
+
38
+ # 2 files:
39
+ # nhk_news_web_easy.yml
40
+ # (only Dec 2019 as an example; more in release)
41
+ # (add comment about above in this file)
42
+ # - 2019-12-25 13:10 JST: (append 1,2,... if duplicate)
43
+ # - url: <url>
44
+ # - md5: <md5sum of content only (in case of ads)>
45
+ # - words:
46
+ # - word (kanji/kana):
47
+ # - kana:
48
+ # - freq:
49
+ # (only Dec 2019 as an example; more in release)
50
+ # nhk_news_web_easy_core_<search criteria>.csv
51
+ # word, kana, freq
52
+ # (sorted by freq, word, or kana [desc/asc])
53
+
54
+ # nhkore --date '2019-12-01...2019-12-11'
55
+ # nhkore --date '2019-12'
56
+ # nhkore --date '12' (Dec of this year)
57
+ # nhkore --date '12-01' (Dec 1 of this year)
58
+
59
+ class Article
60
+ attr_accessor :datetime
61
+ attr_accessor :futsuu_url
62
+ attr_accessor :md5
63
+ attr_accessor :url
64
+ attr_accessor :words
65
+ end
66
+
67
+ word = NHKore::Word.new(kana: 'banana')
68
+ puts word.to_yaml
69
+
70
+ ###
71
+ # @author Jonathan Bradley Whited (@esotericpig)
72
+ # @since 0.1.0
73
+ ###
74
+ module NHKore
75
+ end
76
+
77
+ # https://www3.nhk.or.jp/news/easy
78
+ # https://www.google.com/search?q=site:https://www3.nhk.or.jp/news/easy/&tbas=0&tbs=cdr:1,cd_min:1/1/2019,cd_max:12/31/2019,sbd:1&tbm=nws&sxsrf=ALeKk01oebeT0hWvNro-vDn7WGYkRe0kxw:1582396168988&ei=CHNRXt7dO5KR0QSTnZGYCw&start=20&sa=N&ved=0ahUKEwjega-M5eXnAhWSSJQKHZNOBLM4ChDy0wMIag&biw=1028&bih=672&dpr=1.3
79
+
80
+ #NHKore::App.new().run() if IS_TESTING
@@ -0,0 +1,26 @@
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 Jonathan Bradley Whited (@esotericpig)
8
+ #
9
+ # NHKore is free software: you can redistribute it and/or modify
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/>.
21
+ #++
22
+
23
+
24
+ module NHKore
25
+ VERSION = '0.1.0'
26
+ end
@@ -0,0 +1,79 @@
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 Jonathan Bradley Whited (@esotericpig)
8
+ #
9
+ # NHKore is free software: you can redistribute it and/or modify
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/>.
21
+ #++
22
+
23
+
24
+ module NHKore
25
+ ###
26
+ # @author Jonathan Bradley Whited (@esotericpig)
27
+ # @since 0.1.0
28
+ ###
29
+ class Word
30
+ attr_accessor :freq
31
+ attr_reader :kana
32
+ attr_reader :word
33
+
34
+ def initialize(word=nil,freq: 1,kana: nil,**kargs)
35
+ super()
36
+
37
+ @freq = freq
38
+ @kana = kana
39
+ @word = word.nil?() ? kana : word
40
+
41
+ raise ArgumentError,'word and kana cannot both be nil; one must be specified' if @word.nil?()
42
+ end
43
+
44
+ def encode_with(coder)
45
+ # Ignore @word because it will be the key in the YAML/Hash.
46
+ # Order matters.
47
+ coder[:kana] = @kana
48
+ coder[:freq] = @freq
49
+ end
50
+
51
+ def self.load_hash(key,hash)
52
+ word = Word.new(key,kana: hash[:kana])
53
+
54
+ freq = hash[:freq].to_i() # nil is okay
55
+ word.freq = freq if freq >= 0
56
+
57
+ return word
58
+ end
59
+
60
+ def kanji?()
61
+ return @word != @kana
62
+ end
63
+
64
+ def no_kanji?()
65
+ return !kanji?()
66
+ end
67
+
68
+ def to_s()
69
+ s = ''.dup()
70
+
71
+ s << @word
72
+ s << " | kana: #{@kana}"
73
+ s << " | freq: #{@freq}"
74
+ s << " | kanji? #{kanji?() ? 'yes' : 'no'}"
75
+
76
+ return s
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,72 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ #--
5
+ # This file is part of NHKore.
6
+ # Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
7
+ #
8
+ # NHKore is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU Lesser General Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # NHKore is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public License
19
+ # along with NHKore. If not, see <https://www.gnu.org/licenses/>.
20
+ #++
21
+
22
+
23
+ lib = File.expand_path(File.join('..','lib'),__FILE__)
24
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
25
+
26
+ require 'nhkore/version'
27
+
28
+
29
+ Gem::Specification.new() do |spec|
30
+ spec.name = 'nhkore'
31
+ spec.version = NHKore::VERSION
32
+ spec.authors = ['Jonathan Bradley Whited (@esotericpig)']
33
+ spec.email = ['bradley@esotericpig.com']
34
+ spec.licenses = ['LGPL-3.0-or-later']
35
+ spec.homepage = 'https://github.com/esotericpig/nhkore'
36
+ spec.summary = 'NHK News Web (Easy) word frequency (core) for Japanese language learners.'
37
+ spec.description = 'Scrapes NHK News Web (Easy) for the word frequency (core list) for Japanese language learners.'
38
+
39
+ spec.metadata = {
40
+ 'bug_tracker_uri' => 'https://github.com/esotericpig/nhkore/issues',
41
+ 'changelog_uri' => 'https://github.com/esotericpig/nhkore/blob/master/CHANGELOG.md',
42
+ 'homepage_uri' => 'https://github.com/esotericpig/nhkore',
43
+ 'source_code_uri' => 'https://github.com/esotericpig/nhkore'
44
+ }
45
+
46
+ spec.require_paths = ['lib']
47
+ spec.bindir = 'bin'
48
+ spec.executables = [spec.name]
49
+
50
+ spec.files = Dir.glob(File.join("{#{spec.require_paths.join(',')}}",'**','*.{erb,rb}')) +
51
+ Dir.glob(File.join(spec.bindir,'**',"{#{spec.executables.join(',')}}")) +
52
+ Dir.glob(File.join('{test,yard}','**','*.{erb,rb}')) +
53
+ %W( Gemfile #{spec.name}.gemspec Rakefile ) +
54
+ %w( CHANGELOG.md LICENSE.txt README.md )
55
+
56
+ spec.required_ruby_version = '>= 2.4.0'
57
+
58
+ spec.requirements << 'Nokogiri: https://www.nokogiri.org/tutorials/installing_nokogiri.html'
59
+
60
+ spec.add_runtime_dependency 'commander','~> 4.5' # For CLI
61
+ spec.add_runtime_dependency 'nokogiri' ,'~> 1.10' # For scraping/hacking
62
+ spec.add_runtime_dependency 'psychgus' ,'~> 1.2' # For styling Psych YAML
63
+
64
+ spec.add_development_dependency 'bundler' ,'~> 2.1'
65
+ spec.add_development_dependency 'minitest' ,'~> 5.14'
66
+ spec.add_development_dependency 'rake' ,'~> 13.0'
67
+ spec.add_development_dependency 'raketeer' ,'~> 0.2' # For extra Rake tasks
68
+ spec.add_development_dependency 'yard' ,'~> 0.9' # For documentation
69
+ spec.add_development_dependency 'yard_ghurt','~> 1.1' # For extra YARDoc Rake tasks
70
+
71
+ spec.post_install_message = "You can now use [#{spec.executables.join(', ')}] on the command line."
72
+ end
@@ -0,0 +1,33 @@
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 Jonathan Bradley Whited (@esotericpig)
8
+ #
9
+ # NHKore is free software: you can redistribute it and/or modify
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/>.
21
+ #++
22
+
23
+
24
+ require 'nhkore_tester'
25
+
26
+
27
+ class NHKoreTest < NHKoreTester
28
+ def setup()
29
+ end
30
+
31
+ def test_something()
32
+ end
33
+ end
@@ -0,0 +1,30 @@
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 Jonathan Bradley Whited (@esotericpig)
8
+ #
9
+ # NHKore is free software: you can redistribute it and/or modify
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/>.
21
+ #++
22
+
23
+
24
+ require 'minitest/autorun'
25
+
26
+ require 'nhkore'
27
+
28
+
29
+ class NHKoreTester < Minitest::Test
30
+ end
@@ -0,0 +1,5 @@
1
+ <%# To reduce number of diffs, removed time, YARD version, and Ruby version. %>
2
+ <div id="footer">
3
+ Generated by
4
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>.
5
+ </div>
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nhkore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Bradley Whited (@esotericpig)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: commander
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: psychgus
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.14'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.14'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '13.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '13.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: raketeer
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.2'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.2'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.9'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.9'
125
+ - !ruby/object:Gem::Dependency
126
+ name: yard_ghurt
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.1'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.1'
139
+ description: Scrapes NHK News Web (Easy) for the word frequency (core list) for Japanese
140
+ language learners.
141
+ email:
142
+ - bradley@esotericpig.com
143
+ executables:
144
+ - nhkore
145
+ extensions: []
146
+ extra_rdoc_files: []
147
+ files:
148
+ - CHANGELOG.md
149
+ - Gemfile
150
+ - LICENSE.txt
151
+ - README.md
152
+ - Rakefile
153
+ - bin/nhkore
154
+ - lib/nhkore.rb
155
+ - lib/nhkore/version.rb
156
+ - lib/nhkore/word.rb
157
+ - nhkore.gemspec
158
+ - test/nhkore_test.rb
159
+ - test/nhkore_tester.rb
160
+ - yard/templates/default/layout/html/footer.erb
161
+ homepage: https://github.com/esotericpig/nhkore
162
+ licenses:
163
+ - LGPL-3.0-or-later
164
+ metadata:
165
+ bug_tracker_uri: https://github.com/esotericpig/nhkore/issues
166
+ changelog_uri: https://github.com/esotericpig/nhkore/blob/master/CHANGELOG.md
167
+ homepage_uri: https://github.com/esotericpig/nhkore
168
+ source_code_uri: https://github.com/esotericpig/nhkore
169
+ post_install_message: You can now use [nhkore] on the command line.
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: 2.4.0
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements:
184
+ - 'Nokogiri: https://www.nokogiri.org/tutorials/installing_nokogiri.html'
185
+ rubygems_version: 3.1.2
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: NHK News Web (Easy) word frequency (core) for Japanese language learners.
189
+ test_files: []