kansi_valid 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/GPL +340 -0
- data/README +60 -37
- data/dic/kanji_list.txt +0 -0
- data/kansi_valid.gemspec +12 -2
- data/lib/kansi_valid.rb +57 -176
- data/lib/kansi_valid/kanji.rb +12 -15
- data/lib/kansi_valid/{kansi_analyze.rb → kansi_anaryze.rb} +0 -0
- data/lib/kansi_valid/version.rb +7 -5
- data/lib/kansi_valid/wiktionary.rb +31 -33
- metadata +30 -27
data/GPL
ADDED
@@ -0,0 +1,340 @@
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
2
|
+
Version 2, June 1991
|
3
|
+
|
4
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
5
|
+
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies
|
7
|
+
of this license document, but changing it is not allowed.
|
8
|
+
|
9
|
+
Preamble
|
10
|
+
|
11
|
+
The licenses for most software are designed to take away your
|
12
|
+
freedom to share and change it. By contrast, the GNU General Public
|
13
|
+
License is intended to guarantee your freedom to share and change free
|
14
|
+
software--to make sure the software is free for all its users. This
|
15
|
+
General Public License applies to most of the Free Software
|
16
|
+
Foundation's software and to any other program whose authors commit to
|
17
|
+
using it. (Some other Free Software Foundation software is covered by
|
18
|
+
the GNU Library General Public License instead.) You can apply it to
|
19
|
+
your programs, too.
|
20
|
+
|
21
|
+
When we speak of free software, we are referring to freedom, not
|
22
|
+
price. Our General Public Licenses are designed to make sure that you
|
23
|
+
have the freedom to distribute copies of free software (and charge for
|
24
|
+
this service if you wish), that you receive source code or can get it
|
25
|
+
if you want it, that you can change the software or use pieces of it
|
26
|
+
in new free programs; and that you know you can do these things.
|
27
|
+
|
28
|
+
To protect your rights, we need to make restrictions that forbid
|
29
|
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30
|
+
These restrictions translate to certain responsibilities for you if you
|
31
|
+
distribute copies of the software, or if you modify it.
|
32
|
+
|
33
|
+
For example, if you distribute copies of such a program, whether
|
34
|
+
gratis or for a fee, you must give the recipients all the rights that
|
35
|
+
you have. You must make sure that they, too, receive or can get the
|
36
|
+
source code. And you must show them these terms so they know their
|
37
|
+
rights.
|
38
|
+
|
39
|
+
We protect your rights with two steps: (1) copyright the software, and
|
40
|
+
(2) offer you this license which gives you legal permission to copy,
|
41
|
+
distribute and/or modify the software.
|
42
|
+
|
43
|
+
Also, for each author's protection and ours, we want to make certain
|
44
|
+
that everyone understands that there is no warranty for this free
|
45
|
+
software. If the software is modified by someone else and passed on, we
|
46
|
+
want its recipients to know that what they have is not the original, so
|
47
|
+
that any problems introduced by others will not reflect on the original
|
48
|
+
authors' reputations.
|
49
|
+
|
50
|
+
Finally, any free program is threatened constantly by software
|
51
|
+
patents. We wish to avoid the danger that redistributors of a free
|
52
|
+
program will individually obtain patent licenses, in effect making the
|
53
|
+
program proprietary. To prevent this, we have made it clear that any
|
54
|
+
patent must be licensed for everyone's free use or not licensed at all.
|
55
|
+
|
56
|
+
The precise terms and conditions for copying, distribution and
|
57
|
+
modification follow.
|
58
|
+
|
59
|
+
GNU GENERAL PUBLIC LICENSE
|
60
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61
|
+
|
62
|
+
0. This License applies to any program or other work which contains
|
63
|
+
a notice placed by the copyright holder saying it may be distributed
|
64
|
+
under the terms of this General Public License. The "Program", below,
|
65
|
+
refers to any such program or work, and a "work based on the Program"
|
66
|
+
means either the Program or any derivative work under copyright law:
|
67
|
+
that is to say, a work containing the Program or a portion of it,
|
68
|
+
either verbatim or with modifications and/or translated into another
|
69
|
+
language. (Hereinafter, translation is included without limitation in
|
70
|
+
the term "modification".) Each licensee is addressed as "you".
|
71
|
+
|
72
|
+
Activities other than copying, distribution and modification are not
|
73
|
+
covered by this License; they are outside its scope. The act of
|
74
|
+
running the Program is not restricted, and the output from the Program
|
75
|
+
is covered only if its contents constitute a work based on the
|
76
|
+
Program (independent of having been made by running the Program).
|
77
|
+
Whether that is true depends on what the Program does.
|
78
|
+
|
79
|
+
1. You may copy and distribute verbatim copies of the Program's
|
80
|
+
source code as you receive it, in any medium, provided that you
|
81
|
+
conspicuously and appropriately publish on each copy an appropriate
|
82
|
+
copyright notice and disclaimer of warranty; keep intact all the
|
83
|
+
notices that refer to this License and to the absence of any warranty;
|
84
|
+
and give any other recipients of the Program a copy of this License
|
85
|
+
along with the Program.
|
86
|
+
|
87
|
+
You may charge a fee for the physical act of transferring a copy, and
|
88
|
+
you may at your option offer warranty protection in exchange for a fee.
|
89
|
+
|
90
|
+
2. You may modify your copy or copies of the Program or any portion
|
91
|
+
of it, thus forming a work based on the Program, and copy and
|
92
|
+
distribute such modifications or work under the terms of Section 1
|
93
|
+
above, provided that you also meet all of these conditions:
|
94
|
+
|
95
|
+
a) You must cause the modified files to carry prominent notices
|
96
|
+
stating that you changed the files and the date of any change.
|
97
|
+
|
98
|
+
b) You must cause any work that you distribute or publish, that in
|
99
|
+
whole or in part contains or is derived from the Program or any
|
100
|
+
part thereof, to be licensed as a whole at no charge to all third
|
101
|
+
parties under the terms of this License.
|
102
|
+
|
103
|
+
c) If the modified program normally reads commands interactively
|
104
|
+
when run, you must cause it, when started running for such
|
105
|
+
interactive use in the most ordinary way, to print or display an
|
106
|
+
announcement including an appropriate copyright notice and a
|
107
|
+
notice that there is no warranty (or else, saying that you provide
|
108
|
+
a warranty) and that users may redistribute the program under
|
109
|
+
these conditions, and telling the user how to view a copy of this
|
110
|
+
License. (Exception: if the Program itself is interactive but
|
111
|
+
does not normally print such an announcement, your work based on
|
112
|
+
the Program is not required to print an announcement.)
|
113
|
+
|
114
|
+
These requirements apply to the modified work as a whole. If
|
115
|
+
identifiable sections of that work are not derived from the Program,
|
116
|
+
and can be reasonably considered independent and separate works in
|
117
|
+
themselves, then this License, and its terms, do not apply to those
|
118
|
+
sections when you distribute them as separate works. But when you
|
119
|
+
distribute the same sections as part of a whole which is a work based
|
120
|
+
on the Program, the distribution of the whole must be on the terms of
|
121
|
+
this License, whose permissions for other licensees extend to the
|
122
|
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123
|
+
|
124
|
+
Thus, it is not the intent of this section to claim rights or contest
|
125
|
+
your rights to work written entirely by you; rather, the intent is to
|
126
|
+
exercise the right to control the distribution of derivative or
|
127
|
+
collective works based on the Program.
|
128
|
+
|
129
|
+
In addition, mere aggregation of another work not based on the Program
|
130
|
+
with the Program (or with a work based on the Program) on a volume of
|
131
|
+
a storage or distribution medium does not bring the other work under
|
132
|
+
the scope of this License.
|
133
|
+
|
134
|
+
3. You may copy and distribute the Program (or a work based on it,
|
135
|
+
under Section 2) in object code or executable form under the terms of
|
136
|
+
Sections 1 and 2 above provided that you also do one of the following:
|
137
|
+
|
138
|
+
a) Accompany it with the complete corresponding machine-readable
|
139
|
+
source code, which must be distributed under the terms of Sections
|
140
|
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141
|
+
|
142
|
+
b) Accompany it with a written offer, valid for at least three
|
143
|
+
years, to give any third party, for a charge no more than your
|
144
|
+
cost of physically performing source distribution, a complete
|
145
|
+
machine-readable copy of the corresponding source code, to be
|
146
|
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147
|
+
customarily used for software interchange; or,
|
148
|
+
|
149
|
+
c) Accompany it with the information you received as to the offer
|
150
|
+
to distribute corresponding source code. (This alternative is
|
151
|
+
allowed only for noncommercial distribution and only if you
|
152
|
+
received the program in object code or executable form with such
|
153
|
+
an offer, in accord with Subsection b above.)
|
154
|
+
|
155
|
+
The source code for a work means the preferred form of the work for
|
156
|
+
making modifications to it. For an executable work, complete source
|
157
|
+
code means all the source code for all modules it contains, plus any
|
158
|
+
associated interface definition files, plus the scripts used to
|
159
|
+
control compilation and installation of the executable. However, as a
|
160
|
+
special exception, the source code distributed need not include
|
161
|
+
anything that is normally distributed (in either source or binary
|
162
|
+
form) with the major components (compiler, kernel, and so on) of the
|
163
|
+
operating system on which the executable runs, unless that component
|
164
|
+
itself accompanies the executable.
|
165
|
+
|
166
|
+
If distribution of executable or object code is made by offering
|
167
|
+
access to copy from a designated place, then offering equivalent
|
168
|
+
access to copy the source code from the same place counts as
|
169
|
+
distribution of the source code, even though third parties are not
|
170
|
+
compelled to copy the source along with the object code.
|
171
|
+
|
172
|
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173
|
+
except as expressly provided under this License. Any attempt
|
174
|
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175
|
+
void, and will automatically terminate your rights under this License.
|
176
|
+
However, parties who have received copies, or rights, from you under
|
177
|
+
this License will not have their licenses terminated so long as such
|
178
|
+
parties remain in full compliance.
|
179
|
+
|
180
|
+
5. You are not required to accept this License, since you have not
|
181
|
+
signed it. However, nothing else grants you permission to modify or
|
182
|
+
distribute the Program or its derivative works. These actions are
|
183
|
+
prohibited by law if you do not accept this License. Therefore, by
|
184
|
+
modifying or distributing the Program (or any work based on the
|
185
|
+
Program), you indicate your acceptance of this License to do so, and
|
186
|
+
all its terms and conditions for copying, distributing or modifying
|
187
|
+
the Program or works based on it.
|
188
|
+
|
189
|
+
6. Each time you redistribute the Program (or any work based on the
|
190
|
+
Program), the recipient automatically receives a license from the
|
191
|
+
original licensor to copy, distribute or modify the Program subject to
|
192
|
+
these terms and conditions. You may not impose any further
|
193
|
+
restrictions on the recipients' exercise of the rights granted herein.
|
194
|
+
You are not responsible for enforcing compliance by third parties to
|
195
|
+
this License.
|
196
|
+
|
197
|
+
7. If, as a consequence of a court judgment or allegation of patent
|
198
|
+
infringement or for any other reason (not limited to patent issues),
|
199
|
+
conditions are imposed on you (whether by court order, agreement or
|
200
|
+
otherwise) that contradict the conditions of this License, they do not
|
201
|
+
excuse you from the conditions of this License. If you cannot
|
202
|
+
distribute so as to satisfy simultaneously your obligations under this
|
203
|
+
License and any other pertinent obligations, then as a consequence you
|
204
|
+
may not distribute the Program at all. For example, if a patent
|
205
|
+
license would not permit royalty-free redistribution of the Program by
|
206
|
+
all those who receive copies directly or indirectly through you, then
|
207
|
+
the only way you could satisfy both it and this License would be to
|
208
|
+
refrain entirely from distribution of the Program.
|
209
|
+
|
210
|
+
If any portion of this section is held invalid or unenforceable under
|
211
|
+
any particular circumstance, the balance of the section is intended to
|
212
|
+
apply and the section as a whole is intended to apply in other
|
213
|
+
circumstances.
|
214
|
+
|
215
|
+
It is not the purpose of this section to induce you to infringe any
|
216
|
+
patents or other property right claims or to contest validity of any
|
217
|
+
such claims; this section has the sole purpose of protecting the
|
218
|
+
integrity of the free software distribution system, which is
|
219
|
+
implemented by public license practices. Many people have made
|
220
|
+
generous contributions to the wide range of software distributed
|
221
|
+
through that system in reliance on consistent application of that
|
222
|
+
system; it is up to the author/donor to decide if he or she is willing
|
223
|
+
to distribute software through any other system and a licensee cannot
|
224
|
+
impose that choice.
|
225
|
+
|
226
|
+
This section is intended to make thoroughly clear what is believed to
|
227
|
+
be a consequence of the rest of this License.
|
228
|
+
|
229
|
+
8. If the distribution and/or use of the Program is restricted in
|
230
|
+
certain countries either by patents or by copyrighted interfaces, the
|
231
|
+
original copyright holder who places the Program under this License
|
232
|
+
may add an explicit geographical distribution limitation excluding
|
233
|
+
those countries, so that distribution is permitted only in or among
|
234
|
+
countries not thus excluded. In such case, this License incorporates
|
235
|
+
the limitation as if written in the body of this License.
|
236
|
+
|
237
|
+
9. The Free Software Foundation may publish revised and/or new versions
|
238
|
+
of the General Public License from time to time. Such new versions will
|
239
|
+
be similar in spirit to the present version, but may differ in detail to
|
240
|
+
address new problems or concerns.
|
241
|
+
|
242
|
+
Each version is given a distinguishing version number. If the Program
|
243
|
+
specifies a version number of this License which applies to it and "any
|
244
|
+
later version", you have the option of following the terms and conditions
|
245
|
+
either of that version or of any later version published by the Free
|
246
|
+
Software Foundation. If the Program does not specify a version number of
|
247
|
+
this License, you may choose any version ever published by the Free Software
|
248
|
+
Foundation.
|
249
|
+
|
250
|
+
10. If you wish to incorporate parts of the Program into other free
|
251
|
+
programs whose distribution conditions are different, write to the author
|
252
|
+
to ask for permission. For software which is copyrighted by the Free
|
253
|
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254
|
+
make exceptions for this. Our decision will be guided by the two goals
|
255
|
+
of preserving the free status of all derivatives of our free software and
|
256
|
+
of promoting the sharing and reuse of software generally.
|
257
|
+
|
258
|
+
NO WARRANTY
|
259
|
+
|
260
|
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261
|
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262
|
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263
|
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264
|
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266
|
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267
|
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268
|
+
REPAIR OR CORRECTION.
|
269
|
+
|
270
|
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271
|
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272
|
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273
|
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274
|
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275
|
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276
|
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277
|
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278
|
+
POSSIBILITY OF SUCH DAMAGES.
|
279
|
+
|
280
|
+
END OF TERMS AND CONDITIONS
|
281
|
+
|
282
|
+
How to Apply These Terms to Your New Programs
|
283
|
+
|
284
|
+
If you develop a new program, and you want it to be of the greatest
|
285
|
+
possible use to the public, the best way to achieve this is to make it
|
286
|
+
free software which everyone can redistribute and change under these terms.
|
287
|
+
|
288
|
+
To do so, attach the following notices to the program. It is safest
|
289
|
+
to attach them to the start of each source file to most effectively
|
290
|
+
convey the exclusion of warranty; and each file should have at least
|
291
|
+
the "copyright" line and a pointer to where the full notice is found.
|
292
|
+
|
293
|
+
<one line to give the program's name and a brief idea of what it does.>
|
294
|
+
Copyright (C) <year> <name of author>
|
295
|
+
|
296
|
+
This program is free software; you can redistribute it and/or modify
|
297
|
+
it under the terms of the GNU General Public License as published by
|
298
|
+
the Free Software Foundation; either version 2 of the License, or
|
299
|
+
(at your option) any later version.
|
300
|
+
|
301
|
+
This program is distributed in the hope that it will be useful,
|
302
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304
|
+
GNU General Public License for more details.
|
305
|
+
|
306
|
+
You should have received a copy of the GNU General Public License
|
307
|
+
along with this program; if not, write to the Free Software
|
308
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
309
|
+
|
310
|
+
|
311
|
+
Also add information on how to contact you by electronic and paper mail.
|
312
|
+
|
313
|
+
If the program is interactive, make it output a short notice like this
|
314
|
+
when it starts in an interactive mode:
|
315
|
+
|
316
|
+
Gnomovision version 69, Copyright (C) year name of author
|
317
|
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
318
|
+
This is free software, and you are welcome to redistribute it
|
319
|
+
under certain conditions; type `show c' for details.
|
320
|
+
|
321
|
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
322
|
+
parts of the General Public License. Of course, the commands you use may
|
323
|
+
be called something other than `show w' and `show c'; they could even be
|
324
|
+
mouse-clicks or menu items--whatever suits your program.
|
325
|
+
|
326
|
+
You should also get your employer (if you work as a programmer) or your
|
327
|
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
328
|
+
necessary. Here is a sample; alter the names:
|
329
|
+
|
330
|
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
331
|
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
332
|
+
|
333
|
+
<signature of Ty Coon>, 1 April 1989
|
334
|
+
Ty Coon, President of Vice
|
335
|
+
|
336
|
+
This General Public License does not permit incorporating your program into
|
337
|
+
proprietary programs. If your program is a subroutine library, you may
|
338
|
+
consider it more useful to permit linking proprietary applications with the
|
339
|
+
library. If this is what you want to do, use the GNU Library General
|
340
|
+
Public License instead of this License.
|
data/README
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
#coding:utf-8
|
1
2
|
=== 漢詩を作ったり、解析したりするのに役立つモジュール、関数をつくりました。
|
2
|
-
kansi_valid is a varidator of Han character poem(Kan si).
|
3
|
+
kansi_valid is a varidator of Han character poem(Kan si).
|
3
4
|
Author:: Takayasu Hayashi(林 貴康 joe.ko9ji@gmail.com )
|
4
5
|
License::GPL v2
|
5
6
|
* 辞書の使用は自己責任でお願いします。辞書は漢太郎の作者、Jigen様の作成された辞書を御許可いただきUTF-8テキストにしてあります。Jigen様、ありがとうございます。間違いがありましたら修正したいと思いますのでご連絡ください。joe.ko9ji@gmail.com
|
6
|
-
* Dictionary saved "/dic/dic.txt"UTF-8,about 6800 chars ,made by Jigen Kanou.
|
7
|
-
If you resume this,please tell me.
|
7
|
+
* Dictionary saved "/dic/dic.txt"UTF-8,about 6800 chars ,made by Jigen Kanou.
|
8
|
+
If you resume this,please tell me.
|
8
9
|
* 文字コードは UTF-8 ですので、WinXPなどは出力をKconvで変換したり、対応のエディタで見てください。
|
9
10
|
===:Usage 使い方
|
10
11
|
# coding:utf-8
|
@@ -16,6 +17,17 @@ License::GPL v2
|
|
16
17
|
#winXPなど、文字コードが shift-jisなどのとき
|
17
18
|
require "kconv"
|
18
19
|
print Kconv.kconv(Kansi_valid::sample,Kconv::SJIS,Kconv::UTF8)
|
20
|
+
|
21
|
+
#追記Windows7以降のコンソールで、ruby1.9以降、エラーがでるなら、
|
22
|
+
ruby -Ku kansi_valid_script
|
23
|
+
や
|
24
|
+
ruby -U kansi_valid_script
|
25
|
+
|
26
|
+
script内部で
|
27
|
+
Encoding.default_external = 'utf-8'
|
28
|
+
Encoding.default_internal = 'utf-8'
|
29
|
+
をつかってみてください。(Fixed >=0.0.9)
|
30
|
+
|
19
31
|
=== 先ずは有名なサンプルで。
|
20
32
|
sample # =>"#偶成 朱熹\n少年易老学難成\n一寸光陰不可軽\n未覚池塘春草夢\n階前梧葉已秋声\n"
|
21
33
|
#other valid=>"少年易老学難成\n一寸光陰不可軽\n未覚池塘春草夢\n階前梧葉已秋声"
|
@@ -31,7 +43,7 @@ License::GPL v2
|
|
31
43
|
* srand は同じ詩を生成するために使用していますので通常は不要
|
32
44
|
|
33
45
|
===kansi_valid(String) 絶句ならば禁則評価と辞書の結果表示、research dictionary and answer,validate
|
34
|
-
kansi_valid(sample)
|
46
|
+
str=kansi_valid(sample)
|
35
47
|
# =>#偶成 朱熹
|
36
48
|
少年易老学難成
|
37
49
|
一寸光陰不可軽
|
@@ -53,6 +65,14 @@ License::GPL v2
|
|
53
65
|
|
54
66
|
kv(sample) # =>同上、 same above
|
55
67
|
valid(sample) # =>同上、 same above
|
68
|
+
|
69
|
+
==html化して、wiktionaryなどで文字を調べられるようにするなら、
|
70
|
+
wik=to_wiktionary(str)
|
71
|
+
open("kansi.htm","w"){|io| io.print wik}
|
72
|
+
などとすると、html埋め込みデータができます。(ヘッダ等は必要なら適宜入れてください。)
|
73
|
+
firefox kansi.htm
|
74
|
+
などして、見てください
|
75
|
+
|
56
76
|
=== 文字列が絶句であれば true を返す
|
57
77
|
valid?(sample) # =>true (絶句が正しいならtrue。)
|
58
78
|
(両韻・畳字はtrueを返せない)
|
@@ -96,39 +116,42 @@ License::GPL v2
|
|
96
116
|
hyousoku("菩薩") # =>"虞◇曷●" (韻と平仄式を返す)
|
97
117
|
hyosoku("菩薩") # =>同上、 same above
|
98
118
|
|
99
|
-
|
100
|
-
漢詩のルールにしたがっているかをチェックするスクリプト
|
101
|
-
記号
|
102
|
-
平=韻+○
|
103
|
-
仄=韻+●
|
104
|
-
両韻=◇
|
105
|
-
国字など=■
|
106
|
-
それ以外=?
|
107
|
-
|
108
|
-
チェック可能漢詩:
|
109
|
-
七言絶句
|
110
|
-
五言絶句
|
111
|
-
|
112
|
-
チェック項目
|
113
|
-
押韻、おういん(重複禁)、踏み落とし(三句目)
|
114
|
-
二四不動、にしふどう(挟み平(転句)はOK)
|
115
|
-
二六対、にろくつい(挟み平(転句)はOK)
|
116
|
-
下三連禁、あさんれんきん
|
117
|
-
挟み平(転句はOK)
|
118
|
-
二弧平禁(七言は四弧平禁)
|
119
|
-
冒韻禁,韻字の句内での重複(畳字なども未チェック)
|
120
|
-
|
121
|
-
他のチェック事項
|
122
|
-
韻
|
123
|
-
平起、仄起
|
119
|
+
===漢詩バリデータ(ルールどおりか評価する)ができるまで…
|
120
|
+
漢詩のルールにしたがっているかをチェックするスクリプト
|
121
|
+
記号
|
122
|
+
平=韻+○
|
123
|
+
仄=韻+●
|
124
|
+
両韻=◇
|
125
|
+
国字など=■
|
126
|
+
それ以外=?
|
127
|
+
|
128
|
+
チェック可能漢詩:
|
129
|
+
七言絶句
|
130
|
+
五言絶句
|
131
|
+
|
132
|
+
チェック項目
|
133
|
+
押韻、おういん(重複禁)、踏み落とし(三句目)
|
134
|
+
二四不動、にしふどう(挟み平(転句)はOK)
|
135
|
+
二六対、にろくつい(挟み平(転句)はOK)
|
136
|
+
下三連禁、あさんれんきん
|
137
|
+
挟み平(転句はOK)
|
138
|
+
二弧平禁(七言は四弧平禁)
|
139
|
+
冒韻禁,韻字の句内での重複(畳字なども未チェック)
|
124
140
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
141
|
+
他のチェック事項
|
142
|
+
韻
|
143
|
+
平起、仄起
|
144
|
+
|
145
|
+
やりたいこと
|
146
|
+
読みかた(音、訓)# =>漢字辞書などへ転送など。
|
147
|
+
できてないこと
|
148
|
+
対句,畳字など技法のチェック
|
149
|
+
両韻の振り分けなど(◇でしか対応できない。基本1字1韻対応となる。)
|
150
|
+
たぶんチェックできないこと
|
151
|
+
2、2、3(五言は2,3)の字で区切られているか
|
132
152
|
多少目をつむるなどの融通はきかない。
|
133
153
|
次は詩語表を登録したり、句のまとまりで当てはめられるようにしたい。
|
134
|
-
|
154
|
+
===更新履歴
|
155
|
+
==0.0.9
|
156
|
+
* Windows7 コンソールで、デフォルトでは表示できないので、encodingをUTF-8に決めてあります
|
157
|
+
kansi_valid.rb Fixed
|
data/dic/kanji_list.txt
CHANGED
File without changes
|
data/kansi_valid.gemspec
CHANGED
@@ -1,7 +1,17 @@
|
|
1
1
|
# coding:utf-8
|
2
|
+
if RUBY_VERSION<"1.9"
|
3
|
+
$KCODE="u"
|
4
|
+
else
|
5
|
+
##for execute gemspec and build
|
6
|
+
#2013.2.7 Bug Fix on Windows7 console.(or later version)
|
7
|
+
|
8
|
+
Encoding.default_external = 'utf-8'
|
9
|
+
Encoding.default_internal = 'utf-8'
|
10
|
+
end
|
11
|
+
|
2
12
|
require 'rubygems'
|
3
13
|
require './lib/kansi_valid/version'
|
4
|
-
require './license'
|
14
|
+
#require './license'
|
5
15
|
spec = Gem::Specification.new do |s|
|
6
16
|
s.platform = Gem::Platform::RUBY
|
7
17
|
s.summary = "漢詩の作成補助、添削。 Easy to make Kanshi(Zekku)(Han-poet)and validate it. str=generate(5);kansi_valid(str);kv_bool(str)"
|
@@ -22,7 +32,7 @@ require './license'
|
|
22
32
|
Dir.glob("test/{ts,tc}*.rb")+
|
23
33
|
Dir.glob("dic/*")+
|
24
34
|
#Dir.glob("bin/*.rb")+
|
25
|
-
["kansi_valid.gemspec","LICENSE.txt"]
|
35
|
+
["kansi_valid.gemspec","GPL","LICENSE.txt"]
|
26
36
|
s.test_file="test/tc_kansi_valid.rb"
|
27
37
|
s.extra_rdoc_files="README"
|
28
38
|
s.description = <<EOF
|
data/lib/kansi_valid.rb
CHANGED
@@ -1,171 +1,52 @@
|
|
1
1
|
#coding:utf-8
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
if RUBY_VERSION<"1.9"
|
3
|
+
$KCODE="u"
|
4
|
+
else
|
5
|
+
#2013.2.7 Bug Fix on Windows7 console.(or later version)
|
6
|
+
Encoding.default_external = 'utf-8'
|
7
|
+
Encoding.default_internal = 'utf-8'
|
8
|
+
end
|
9
|
+
|
10
|
+
File.expand_path(File.dirname(__FILE__))
|
11
|
+
File.expand_path(File.dirname(__FILE__)+"../dic")
|
12
|
+
|
13
|
+
Dir.glob(File.dirname(__FILE__)+"/kansi_valid/*.rb").each do |file|
|
14
|
+
p file if $DEBUG
|
15
|
+
require file
|
16
|
+
end
|
11
17
|
|
12
|
-
|
13
|
-
#kansi_valid is a varidator of Han character poem(Kan si).
|
14
|
-
#Author:: Takayasu Hayashi(林 貴康 joe.ko9ji@gmail.com )
|
15
|
-
#License::GPL v2
|
16
|
-
#* 辞書の使用は自己責任でお願いします。辞書は漢太郎の作者、Jigen様の作成された辞書を御許可いただきUTF-8テキストにしてあります。Jigen様、ありがとうございます。間違いがありましたら修正したいと思いますのでご連絡ください。
|
17
|
-
#* Dictionary saved "/dic/dic.txt"UTF-8,about 6800 chars ,made by Jigen Kanou.
|
18
|
-
# If you resume this,please tell me.
|
19
|
-
#* 文字コードは UTF-8 ですので、WinXPなどは出力をKconvで変換したり、対応のエディタで見てください。
|
20
|
-
#===:Usage 使い方
|
21
|
-
# requrie "rubyems" if "RUBY_VERSION"<"1.9"
|
22
|
-
# require "kansi_valid"
|
23
|
-
# include Kansi_valid
|
24
|
-
# puts kv(generate)
|
25
|
-
#
|
26
|
-
#=== 先ずは有名なサンプルで。
|
27
|
-
# sample # =>"#偶成 朱熹\n少年易老学難成\n一寸光陰不可軽\n未覚池塘春草夢\n階前梧葉已秋声\n"
|
28
|
-
# #other valid=>"少年易老学難成\n一寸光陰不可軽\n未覚池塘春草夢\n階前梧葉已秋声"
|
29
|
-
# #other valid=>"少年易老学難成 一寸光陰不可軽 未覚池塘春草夢 階前梧葉已秋声"
|
30
|
-
# #other valid=>"少年易老学難成一寸光陰不可軽未覚池塘春草夢階前梧葉已秋声"
|
31
|
-
#
|
32
|
-
#===漢詩ではないサンプル漢詩を機械的に生成します
|
33
|
-
# samples(10) # =>make many 'Meaningless' poet.
|
34
|
-
#
|
35
|
-
#* 七言絶句(7を指定)五言絶句(5を指定) make random 'Meaningless' poet(7or5 gon Zekku)
|
36
|
-
# srand(0);str1 = generate(7) # => "戻里唆双差及援\n罷傷脈拘序周元\n家据弱役露宵屋\n稚守途紅稿軸温"
|
37
|
-
# srand(0);generate(5) # => "戻里唆双飯\n差猫及硬温\n除慌女収嫁\n枢寂厄痴援"
|
38
|
-
#* srand は同じ詩を生成するために使用していますので通常は不要
|
39
|
-
#
|
40
|
-
#===kansi_valid(String) 絶句ならば禁則評価と辞書の結果表示、research dictionary and answer,validate
|
41
|
-
# kansi_valid(sample)
|
42
|
-
# # =>#偶成 朱熹
|
43
|
-
# 少年易老学難成
|
44
|
-
# 一寸光陰不可軽
|
45
|
-
# 未覚池塘春草夢
|
46
|
-
# 階前梧葉已秋声
|
47
|
-
#
|
48
|
-
# # 庚 平起
|
49
|
-
# #篠●先○陌●皓●覚●寒◇庚○
|
50
|
-
# #質●願●陽○侵◇物◇哿●庚◇
|
51
|
-
# #未●覚●支○陽○真○皓●東◇
|
52
|
-
# #佳○先○虞◇葉●紙●尤○庚○
|
53
|
-
# #Valid 絶句(Ver0.0.6)
|
54
|
-
# #2013-01-03 22:58:18 +0900
|
55
|
-
#
|
56
|
-
# #少:●:篠:嘯:ショウ:すくない すこし わかい
|
57
|
-
# #年:○:一先::ネン:とし よわい みのり
|
58
|
-
# 以下省略#
|
59
|
-
#
|
60
|
-
# kv(sample) # =>同上、 same above
|
61
|
-
# valid(sample) # =>同上、 same above
|
62
|
-
#=== 文字列が絶句であれば true を返す
|
63
|
-
# valid?(sample) # =>true (絶句が正しいならtrue。)
|
64
|
-
# (両韻・畳字などはtrueを返せない)
|
65
|
-
# kv_bool(sample) # =>同上、 same above
|
66
|
-
#
|
67
|
-
#===漢詩でないものも第二水準漢字程度まで調べられます。日本の国字<峠辻>なども調べられますが、絶句の評価はできません。 3
|
68
|
-
# dic("漢字辞典") # =>文字列を調べる。普通こちら、Simple dictionary using Dic[]
|
69
|
-
# # =>"漢:●:翰::カン:国名 あや から
|
70
|
-
# 字:●:寘::ジ:あざ あざな じ
|
71
|
-
# 辞:○:四支::ジ:やめる ことば ことわる
|
72
|
-
# 典:●:銑::テン:ふみ のり つかさどる
|
73
|
-
# "
|
74
|
-
# Dic["漢"] # =>単漢字を調べる、Character Hash Dictionary(Author Jigen Kanou,in Kantarou)
|
75
|
-
# # =>["漢", "413", "", "0", "●", "翰", "去声", "", "カン", "",
|
76
|
-
# "国名 あや から", "3441", "2033", "13", "水艸口夫漢", "0"]
|
77
|
-
#
|
78
|
-
#=== 辞書の音訓などから調べる場合は search を使います
|
79
|
-
# search("かえで") # =>Dicの内容から該当する漢字のハッシュをつくる
|
80
|
-
# # =>{"楓"=>["楓", "2440", "", "0", "○", "一東", "上平", "", "フウ", "",
|
81
|
-
# "かえで", "4976", "4186", "13", "木風几丿虫", "0"],
|
82
|
-
# "槭"=>["槭", "4166", "", "0", "●", "屋", "入声", "", "セキ", "",
|
83
|
-
# "かえで", "5C65", "6069", "15", "木戚戈上小", "0"]}
|
84
|
-
#===平韻の字表の配列です
|
85
|
-
# inji # =>平韻の配列表(inji[x],x=0..29)
|
86
|
-
# (inji[0]が一東です)
|
87
|
-
# inji[29] # =>"咸銜鹹緘岩巌杉衫凡鑑函監讒帆"
|
88
|
-
#===常用漢字の配列です(約1945字)
|
89
|
-
# Jouyou=["哀","愛",..,"湾","腕"]
|
90
|
-
#===全ての辞書漢字の配列です(約6715字、国字など含む。)
|
91
|
-
# Ji =["亜","唖",..,"禔","赶"]
|
92
|
-
#
|
93
|
-
#===平仄韻からランダムに文字をあてはめます
|
94
|
-
# poetter("常国◇○●\n◇○○●◎\n○○●○●\n○●●○◎",[Jouyou,inji[0]])
|
95
|
-
# # =>"常国雇坪坂\n飲戯眠分崇\n諸番襲硝看\n評緯越然籠"
|
96
|
-
# zekku_list # =>絶句として適したルールの配列
|
97
|
-
# kougo("◇●常国○◎") # =>"囚故常国挑琴\n#侵" 平仄式から字を充て、最後に韻をコメント。
|
98
|
-
# # "◇不問 ●仄 ○平 ◎韻"
|
99
|
-
# kougo() # =>無意味な香語調を生成します、make random 'Meaningless' "kougo".
|
100
|
-
#
|
101
|
-
#
|
102
|
-
# hyousoku("菩薩") # =>"虞◇曷●" (韻と平仄式を返す)
|
103
|
-
# hyosoku("菩薩") # =>同上、 same above
|
104
|
-
#
|
105
|
-
#==参考 漢詩バリデータ(ルールどおりか評価する)を作るまで
|
106
|
-
# 漢詩のルールにしたがっているかをチェックするスクリプト
|
107
|
-
# 記号
|
108
|
-
# 平=韻+○
|
109
|
-
# 仄=韻+●
|
110
|
-
# 両韻=◇
|
111
|
-
# 国字など=■
|
112
|
-
# それ以外=?
|
113
|
-
#
|
114
|
-
# チェック可能漢詩:
|
115
|
-
# 七言絶句
|
116
|
-
# 五言絶句
|
117
|
-
#
|
118
|
-
# チェック項目
|
119
|
-
# 押韻、おういん(重複禁)、踏み落とし(三句目)
|
120
|
-
# 二四不動、にしふどう(挟み平(転句)はOK)
|
121
|
-
# 二六対、にろくつい(挟み平(転句)はOK)
|
122
|
-
# 下三連禁、あさんれんきん
|
123
|
-
# 挟み平(転句はOK)
|
124
|
-
# 二弧平禁(七言は四弧平禁)
|
125
|
-
# 冒韻禁,韻字の句内での重複(畳字なども未チェック)
|
126
|
-
#
|
127
|
-
# 他のチェック事項
|
128
|
-
# 韻
|
129
|
-
# 平起、仄起
|
130
|
-
#
|
131
|
-
# やりたいこと
|
132
|
-
# 読みかた(音、訓)# =>漢字辞書などへ転送など。
|
133
|
-
# できてないこと
|
134
|
-
# 対句,畳字など技法のチェック
|
135
|
-
# 両韻の振り分けなど(◇でしか対応できない。基本1字1韻対応となる。)
|
136
|
-
# たぶんチェックできないこと
|
137
|
-
# 2、2、3(五言は2,3)の字で区切られているか
|
138
|
-
# 多少目をつむるなどの融通はきかない。
|
139
|
-
module Kansi_valid
|
18
|
+
module Kansi_valid
|
140
19
|
module_function
|
141
20
|
#全辞書ハッシュ
|
142
|
-
Dic=kanji
|
21
|
+
Dic=kanji
|
143
22
|
#常用漢字の配列
|
144
23
|
Jouyou=File.read(File.dirname(__FILE__)+"/../dic/jouyou_kanji.txt").chomp.split(//)
|
145
|
-
|
24
|
+
|
25
|
+
#辞書の全ての漢字の配列(ひらがな等は、除外、国字は含む)
|
146
26
|
Ji =File.read(File.dirname(__FILE__)+"/../dic/kanji_list.txt").chomp.split(//)
|
147
|
-
|
148
|
-
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
#
|
160
|
-
#
|
161
|
-
# #
|
162
|
-
#
|
163
|
-
#
|
164
|
-
#
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
27
|
+
|
28
|
+
#===kansi_valid(String) 絶句ならば禁則評価と辞書の結果表示、research dictionary and answer,validate
|
29
|
+
# kansi_valid(sample)
|
30
|
+
# # =>#偶成 朱熹
|
31
|
+
# 少年易老学難成
|
32
|
+
# 一寸光陰不可軽
|
33
|
+
# 未覚池塘春草夢
|
34
|
+
# 階前梧葉已秋声
|
35
|
+
#
|
36
|
+
# # 庚 平起
|
37
|
+
# #篠●先○陌●皓●覚●寒◇庚○
|
38
|
+
# #質●願●陽○侵◇物◇哿●庚◇
|
39
|
+
# #未●覚●支○陽○真○皓●東◇
|
40
|
+
# #佳○先○虞◇葉●紙●尤○庚○
|
41
|
+
# #Valid 絶句(Ver0.0.6)
|
42
|
+
# #2013-01-03 22:58:18 +0900
|
43
|
+
#
|
44
|
+
# #少:●:篠:嘯:ショウ:すくない すこし わかい
|
45
|
+
# #年:○:一先::ネン:とし よわい みのり
|
46
|
+
# 以下省略#
|
47
|
+
#
|
48
|
+
# kv(sample) # =>同上、 same above
|
49
|
+
# valid(sample) # =>同上、 same above
|
169
50
|
def kansi_valid(str)
|
170
51
|
begin
|
171
52
|
comment=kansi_comment(str)#コメントの切り出し
|
@@ -222,10 +103,10 @@ module_function
|
|
222
103
|
#冒韻禁,韻字の句内での重複
|
223
104
|
_bouin=bouin(a,zekku,ouIn)&&tuuIn#韻を踏んで(tuuin==true)更にbouin==true
|
224
105
|
p warning if $DEBUG
|
225
|
-
warning="#Valid 絶句(Ver#{Version})\n##{Time.now.to_s}\n" if warning==""
|
106
|
+
warning="#Valid 絶句(Ver#{Version})\n##{Time.now.to_s}\n" if warning==""
|
226
107
|
unless _bouin
|
227
108
|
warning+="# 注・畳字、両韻文字、または冒韻\n"
|
228
|
-
end
|
109
|
+
end
|
229
110
|
|
230
111
|
ryouin_list=check_ryouin(kansi_organize(str))
|
231
112
|
|
@@ -237,13 +118,13 @@ module_function
|
|
237
118
|
yield result if block_given?
|
238
119
|
return result
|
239
120
|
end
|
240
|
-
end
|
121
|
+
end
|
241
122
|
|
242
|
-
#=== 文字列が絶句であれば true を返す
|
243
|
-
# valid?(sample) # =>true (絶句が正しいならtrue。)
|
244
|
-
# (両韻・畳字などはtrueを返せない)
|
245
|
-
# kv_bool(sample) # =>同上、 same above
|
246
|
-
#
|
123
|
+
#=== 文字列が絶句であれば true を返す
|
124
|
+
# valid?(sample) # =>true (絶句が正しいならtrue。)
|
125
|
+
# (両韻・畳字などはtrueを返せない)
|
126
|
+
# kv_bool(sample) # =>同上、 same above
|
127
|
+
#
|
247
128
|
def kv_bool(str)
|
248
129
|
bool=true
|
249
130
|
begin
|
@@ -306,16 +187,16 @@ module_function
|
|
306
187
|
end
|
307
188
|
|
308
189
|
alias kv kansi_valid
|
309
|
-
alias valid kansi_valid
|
310
|
-
|
190
|
+
alias valid kansi_valid
|
191
|
+
|
311
192
|
alias dic check_ryouin
|
312
|
-
|
193
|
+
|
313
194
|
alias hyosoku hyousoku
|
314
195
|
alias kansi_ kansi_organize
|
315
|
-
alias kohyou kohyo
|
316
|
-
|
317
|
-
alias valid? kv_bool
|
318
|
-
alias bool kv_bool
|
196
|
+
alias kohyou kohyo
|
197
|
+
|
198
|
+
alias valid? kv_bool
|
199
|
+
alias bool kv_bool
|
319
200
|
|
320
201
|
alias generate kansi_generate
|
321
202
|
alias generate2 kansi_generate2
|
data/lib/kansi_valid/kanji.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
# coding:utf-8
|
2
2
|
|
3
3
|
module Kansi_valid
|
4
|
-
module_function
|
5
|
-
def kanji(dic_file=File.dirname(__FILE__)+"/../../dic/dic.txt")
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
module_function:kanji
|
18
|
-
end
|
4
|
+
module_function
|
5
|
+
def kanji(dic_file=File.dirname(__FILE__)+"/../../dic/dic.txt")
|
6
|
+
dic={}
|
7
|
+
data=File.read(dic_file)
|
8
|
+
data.each_line do |list|
|
9
|
+
data=list.chomp.split(";")
|
10
|
+
dic[data[0]]=data
|
11
|
+
end
|
12
|
+
return dic
|
13
|
+
end
|
14
|
+
module_function:kanji
|
15
|
+
end
|
File without changes
|
data/lib/kansi_valid/version.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
# coding:utf-8
|
2
2
|
|
3
|
-
module Kansi_valid
|
3
|
+
module Kansi_valid
|
4
4
|
module_function
|
5
|
-
Version = '0.0.
|
5
|
+
Version = '0.0.10'
|
6
6
|
|
7
|
-
CHENGE_LOG="'0.0.
|
7
|
+
CHENGE_LOG="'0.0.10' 0.0.9 error in rdoc(win7)
|
8
|
+
'0.0.9' BugFixed kansi_valid.rb (RUBY >=1.9)ENCODING ERROR on Windows7(or later) console.
|
9
|
+
'0.0.8' kansi_valid Bug fixed.(_bouin word+=...)
|
8
10
|
'0.0.7' Also use NameSpace (module_function add).
|
9
11
|
'0.0.6' Rdoc error fixed. UnitTest add.
|
10
12
|
'0.0.5' search() add.
|
11
13
|
'0.0.4' Linux support. ,delete 'win32ole'
|
12
14
|
'0.0.3' for win 2009.2.6Takayasu_H
|
13
|
-
'0.0.2' some bug fix
|
15
|
+
'0.0.2' some bug fix
|
14
16
|
'0.0.1' first on windows XP. Thanks Kantarou(Author:Jigen Konou),and its great dictionary."
|
15
|
-
end
|
17
|
+
end
|
@@ -1,30 +1,30 @@
|
|
1
1
|
#coding:utf-8
|
2
2
|
require 'uri'
|
3
|
-
|
3
|
+
|
4
4
|
module Kansi_valid
|
5
|
-
module_function
|
6
|
-
##
|
7
|
-
#===文字データベースのwiktionary:
|
8
|
-
# http://en.wiktionary.org/wiki/
|
9
|
-
# で文字を調べるように、urlを作成する(1字のみ)
|
10
|
-
#===exsample:
|
11
|
-
# wiktionary("字") # =>"http://en.wiktionary.org/wiki/%E5%AD%97"
|
12
|
-
#
|
13
|
-
# to_wiktionary
|
14
|
-
# ref
|
5
|
+
module_function
|
6
|
+
##
|
7
|
+
#===文字データベースのwiktionary:
|
8
|
+
# http://en.wiktionary.org/wiki/
|
9
|
+
# で文字を調べるように、urlを作成する(1字のみ)
|
10
|
+
#===exsample:
|
11
|
+
# wiktionary("字") # =>"http://en.wiktionary.org/wiki/%E5%AD%97"
|
12
|
+
#
|
13
|
+
# to_wiktionary
|
14
|
+
# ref
|
15
15
|
def wiktionary(str)
|
16
16
|
str_uri = URI.escape("http://en.wiktionary.org/wiki/#{str}")
|
17
17
|
end
|
18
18
|
|
19
|
-
##
|
20
|
-
#===文字データベースのwiktionary
|
21
|
-
# http://en.wiktionary.org/wiki/
|
22
|
-
# で文字を調べるように、urlを作成する(1字のみ)
|
23
|
-
# htmlに貼り付けるリンク向きです。
|
24
|
-
#===exsample:
|
25
|
-
# ref("字") # =>"<a href=\"http://en.wiktionary.org/wiki/%E5%AD%97\" target=\"_blank\">字</a>"
|
26
|
-
# :to_wiktionary
|
27
|
-
# :wiktionary
|
19
|
+
##
|
20
|
+
#===文字データベースのwiktionary
|
21
|
+
# http://en.wiktionary.org/wiki/
|
22
|
+
# で文字を調べるように、urlを作成する(1字のみ)
|
23
|
+
# htmlに貼り付けるリンク向きです。
|
24
|
+
#===exsample:
|
25
|
+
# ref("字") # =>"<a href=\"http://en.wiktionary.org/wiki/%E5%AD%97\" target=\"_blank\">字</a>"
|
26
|
+
# :to_wiktionary
|
27
|
+
# :wiktionary
|
28
28
|
def ref(str)
|
29
29
|
#str should be 1 char
|
30
30
|
|
@@ -37,17 +37,17 @@ module_function
|
|
37
37
|
end
|
38
38
|
return x
|
39
39
|
end
|
40
|
-
|
41
|
-
##
|
42
|
-
#===文字データベースのwiktionary
|
43
|
-
# http://en.wiktionary.org/wiki/
|
44
|
-
# で文字を調べるように、urlを作成する
|
45
|
-
#
|
46
|
-
#===exsample:
|
47
|
-
# to_wiktionary("漢字")# =>"<a href=\"http://en.wiktionary.org/wiki/%E6%BC%A2\" target=\"_blank\">漢</a>
|
48
|
-
# <a href=\"http://en.wiktionary.org/wiki/%E5%AD%97\" target=\"_blank\">字</a>
|
49
|
-
#wiktionary
|
50
|
-
#ref
|
40
|
+
|
41
|
+
##
|
42
|
+
#===文字データベースのwiktionary
|
43
|
+
# http://en.wiktionary.org/wiki/
|
44
|
+
# で文字を調べるように、urlを作成する
|
45
|
+
# こちらは多文字に対応している。
|
46
|
+
#===exsample:
|
47
|
+
# to_wiktionary("漢字")# =>"<a href=\"http://en.wiktionary.org/wiki/%E6%BC%A2\" target=\"_blank\">漢</a>
|
48
|
+
# <a href=\"http://en.wiktionary.org/wiki/%E5%AD%97\" target=\"_blank\">字</a>
|
49
|
+
#wiktionary
|
50
|
+
#ref
|
51
51
|
def to_wiktionary(str)
|
52
52
|
kekka=""
|
53
53
|
flag=true #perse flag
|
@@ -70,8 +70,6 @@ module_function
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
|
-
#kekka+="<br/><p>単漢字をクリックすると辞書へ移動します。!!</p>"
|
74
|
-
|
75
73
|
yield kekka if block_given?
|
76
74
|
return kekka
|
77
75
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kansi_valid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-07 00:00:00.000000000 +09:00
|
13
|
+
default_executable:
|
13
14
|
dependencies: []
|
14
15
|
description: ! "Usage:\n requrie \"rubyems\"\n require \"Kansi_valid\"\n inclide
|
15
16
|
Kansi_valid\n \n puts str1 = generate(7) # => make random poet(7 gon Zekku)\n
|
@@ -23,45 +24,47 @@ extensions: []
|
|
23
24
|
extra_rdoc_files:
|
24
25
|
- README
|
25
26
|
files:
|
26
|
-
- lib/kansi_valid.rb
|
27
|
-
- lib/kansi_valid/hyousoku.rb
|
28
|
-
- lib/kansi_valid/check_ouin.rb
|
29
|
-
- lib/kansi_valid/inji.rb
|
30
|
-
- lib/kansi_valid/check_tuuin.rb
|
31
|
-
- lib/kansi_valid/kansi_generate.rb
|
32
27
|
- lib/kansi_valid/sample.rb
|
33
|
-
- lib/kansi_valid/
|
28
|
+
- lib/kansi_valid/kansi_htm.rb
|
29
|
+
- lib/kansi_valid/check_tuuin.rb
|
30
|
+
- lib/kansi_valid/nihongo.rb
|
31
|
+
- lib/kansi_valid/be_hyo.rb
|
34
32
|
- lib/kansi_valid/pick.rb
|
35
|
-
- lib/kansi_valid/
|
33
|
+
- lib/kansi_valid/version.rb
|
34
|
+
- lib/kansi_valid/be_soku.rb
|
36
35
|
- lib/kansi_valid/bouin.rb
|
37
|
-
- lib/kansi_valid/
|
38
|
-
- lib/kansi_valid/check_zekku.rb
|
39
|
-
- lib/kansi_valid/nihongo.rb
|
40
|
-
- lib/kansi_valid/kansi_htm.rb
|
41
|
-
- lib/kansi_valid/kansi_analyze.rb
|
36
|
+
- lib/kansi_valid/check_ouin.rb
|
42
37
|
- lib/kansi_valid/kansi_organize.rb
|
43
|
-
- lib/kansi_valid/
|
44
|
-
- lib/kansi_valid/version.rb
|
45
|
-
- lib/kansi_valid/kanji.rb
|
38
|
+
- lib/kansi_valid/kansi_generate.rb
|
46
39
|
- lib/kansi_valid/seikei.rb
|
47
|
-
- lib/kansi_valid/
|
48
|
-
- lib/kansi_valid/
|
49
|
-
- lib/kansi_valid/be_hyo.rb
|
40
|
+
- lib/kansi_valid/hyousoku.rb
|
41
|
+
- lib/kansi_valid/check_zekku.rb
|
50
42
|
- lib/kansi_valid/wiktionary.rb
|
43
|
+
- lib/kansi_valid/_24hudou.rb
|
44
|
+
- lib/kansi_valid/search.rb
|
45
|
+
- lib/kansi_valid/kanji.rb
|
46
|
+
- lib/kansi_valid/inji.rb
|
47
|
+
- lib/kansi_valid/kohyo.rb
|
51
48
|
- lib/kansi_valid/kansi_comment.rb
|
49
|
+
- lib/kansi_valid/_3ren.rb
|
52
50
|
- lib/kansi_valid/check_okosi.rb
|
53
|
-
- lib/kansi_valid/
|
51
|
+
- lib/kansi_valid/check_ryouin.rb
|
52
|
+
- lib/kansi_valid/kansi_anaryze.rb
|
53
|
+
- lib/kansi_valid/kougo.rb
|
54
|
+
- lib/kansi_valid.rb
|
54
55
|
- test/tc_kansi_valid.rb
|
55
|
-
- dic/yomi.dic
|
56
|
-
- dic/kaku.dic
|
57
|
-
- dic/kanji_list.txt
|
58
56
|
- dic/parts.dic
|
59
|
-
- dic/dic.txt
|
60
57
|
- dic/jouyou_kanji.txt
|
58
|
+
- dic/dic.txt
|
59
|
+
- dic/kaku.dic
|
61
60
|
- dic/ji_s.txt
|
61
|
+
- dic/yomi.dic
|
62
|
+
- dic/kanji_list.txt
|
62
63
|
- kansi_valid.gemspec
|
64
|
+
- GPL
|
63
65
|
- LICENSE.txt
|
64
66
|
- README
|
67
|
+
has_rdoc: true
|
65
68
|
homepage:
|
66
69
|
licenses: []
|
67
70
|
post_install_message:
|
@@ -82,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
85
|
version: '0'
|
83
86
|
requirements: []
|
84
87
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.
|
88
|
+
rubygems_version: 1.6.2
|
86
89
|
signing_key:
|
87
90
|
specification_version: 3
|
88
91
|
summary: 漢詩の作成補助、添削。 Easy to make Kanshi(Zekku)(Han-poet)and validate it. str=generate(5);kansi_valid(str);kv_bool(str)
|