Compare commits
11 Commits
7e9f57b113
...
cc9bc30b68
Author | SHA1 | Date | |
---|---|---|---|
cc9bc30b68 | |||
2e3194aa18 | |||
|
221e25544d | ||
|
81e4b4ba8e | ||
|
5dd00f3bcb | ||
|
3a04f83b51 | ||
|
b77b2f92fd | ||
8c7ddb0c20 | |||
a81499578b | |||
|
808d66c7b0 | ||
|
1bad2ace3a |
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
|||||||
Copyright 2016-2019 Alex Yatskov
|
Copyright 2016-2022 Alex Yatskov
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
# JMDict #
|
# JMDict
|
||||||
|
|
||||||
JMDict is a simple library written in Go for parsing the raw data files for the
|
JMDict is a simple library written in Go for parsing the raw data files for the
|
||||||
[JMDict](http://www.edrdg.org/enamdict/enamdict_doc.html) (vocabulary)
|
[JMDict](http://www.edrdg.org/jmdict/j_jmdict.html) (vocabulary)
|
||||||
[JMnedict](http://www.edrdg.org/enamdict/enamdict_doc.html) (names), and
|
[JMnedict](http://www.edrdg.org/enamdict/enamdict_doc.html) (names), and
|
||||||
[KANJIDIC](http://nihongo.monash.edu/kanjidic2/index.html) (Kanji) dictionaries. As far as I know, these are the only
|
[KANJIDIC](http://nihongo.monash.edu/kanjidic2/index.html) (Kanji) dictionaries. As far as I know, these are the only
|
||||||
publicly available Japanese dictionaries and are therefore used by a variety of tools (including
|
publicly available Japanese dictionaries and are therefore used by a variety of tools (including
|
||||||
[Yomichan-Import](https://foosoft.net/projects/yomichan-import) from this site).
|
[Yomichan-Import](https://foosoft.net/projects/yomichan-import) from this site).
|
||||||
|
|
||||||
The XML format used to store dictionary entries and entity data was deceptively annoying to work with, leading to the
|
The XML format used to store dictionary entries and entity data was deceptively annoying to work with, leading to the
|
||||||
creation of this library. Please see the [documentation page](https://godoc.org/github.com/FooSoft/jmdict) for a
|
creation of this library. Please see the [documentation page](https://godoc.org/foosoft.net/projects/jmdict) for a
|
||||||
technical overview of how to use this library.
|
technical overview of how to use this library.
|
||||||
|
|
||||||
|
Please import this library from `foosoft.net/projects/jmdict` and not the GitHub path.
|
||||||
|
22
common.go
22
common.go
@ -1,25 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Alex Yatskov <alex@foosoft.net>
|
|
||||||
* Author: Alex Yatskov <alex@foosoft.net>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
|
||||||
* the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package jmdict
|
package jmdict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
60
jmdict.go
60
jmdict.go
@ -1,25 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Alex Yatskov <alex@foosoft.net>
|
|
||||||
* Author: Alex Yatskov <alex@foosoft.net>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
|
||||||
* the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package jmdict
|
package jmdict
|
||||||
|
|
||||||
import "io"
|
import "io"
|
||||||
@ -170,6 +148,13 @@ type JmdictGlossary struct {
|
|||||||
// a noun in the target language. When absent, the gender is either
|
// a noun in the target language. When absent, the gender is either
|
||||||
// not relevant or has yet to be provided.
|
// not relevant or has yet to be provided.
|
||||||
Gender *string `xml:"g_gend"`
|
Gender *string `xml:"g_gend"`
|
||||||
|
|
||||||
|
// g_type attribute added in jmdict Rev 1.09
|
||||||
|
// At present the values used are "lit", "fig", "expl" and "tm". It is
|
||||||
|
// proposed to add a "descr" value to indicate a gloss which is a
|
||||||
|
// description of the Japanese term rather than a translation or an
|
||||||
|
// explanation of the meaning.
|
||||||
|
Type *string `xml:"g_type,attr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type JmdictSense struct {
|
type JmdictSense struct {
|
||||||
@ -229,6 +214,37 @@ type JmdictSense struct {
|
|||||||
// Japanese word. This element would normally be present, however it
|
// Japanese word. This element would normally be present, however it
|
||||||
// may be omitted in entries which are purely for a cross-reference.
|
// may be omitted in entries which are purely for a cross-reference.
|
||||||
Glossary []JmdictGlossary `xml:"gloss"`
|
Glossary []JmdictGlossary `xml:"gloss"`
|
||||||
|
|
||||||
|
// Some JMdict entries can contain 0 or more examples
|
||||||
|
Examples []JmdictExample `xml:"example"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JmdictExample struct {
|
||||||
|
// Each example has a Srce element that indicates the source of the example
|
||||||
|
// the source is typically the Tatoeba Project
|
||||||
|
Srce JmdictExampleSource `xml:"ex_srce"`
|
||||||
|
|
||||||
|
// The term associated with this example
|
||||||
|
Text string `xml:"ex_text"`
|
||||||
|
|
||||||
|
// Contains the Example sentences
|
||||||
|
Sentences []JmdictExampleSentence `xml:"ex_sent"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JmdictExampleSource struct {
|
||||||
|
// The id of the example for the source
|
||||||
|
ID string `xml:",chardata"`
|
||||||
|
|
||||||
|
// The source type (i.e. 'tat' for tatoeba)
|
||||||
|
SrcType string `xml:"exsrc_type,attr"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JmdictExampleSentence struct {
|
||||||
|
// The language of the example sentence
|
||||||
|
Lang string `xml:"lang,attr"`
|
||||||
|
|
||||||
|
// The example sentence text
|
||||||
|
Text string `xml:",chardata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadJmdict(reader io.Reader) (Jmdict, map[string]string, error) {
|
func LoadJmdict(reader io.Reader) (Jmdict, map[string]string, error) {
|
||||||
|
22
jmnedict.go
22
jmnedict.go
@ -1,25 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Alex Yatskov <alex@foosoft.net>
|
|
||||||
* Author: Alex Yatskov <alex@foosoft.net>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
|
||||||
* the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package jmdict
|
package jmdict
|
||||||
|
|
||||||
import "io"
|
import "io"
|
||||||
|
22
kanjidic.go
22
kanjidic.go
@ -1,25 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Alex Yatskov <alex@foosoft.net>
|
|
||||||
* Author: Alex Yatskov <alex@foosoft.net>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
|
||||||
* the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package jmdict
|
package jmdict
|
||||||
|
|
||||||
import "io"
|
import "io"
|
||||||
|
Loading…
Reference in New Issue
Block a user