Coder Social home page Coder Social logo

yomitan-dic's Introduction

YomitanDic

YomitanDic is a Python library that makes it easy to create dictionary files importable into Yomitan for Japanese popup dictionaries. With YomitanDic, you can quickly create dictionary entries with definitions, links, and custom HTML elements.

YomitanDic offers a high degree of customisability but also simpler methods too!

Installation

To install YomitanDic, use pip:

pip install yomitandic

or to update yomitandic (may need to run the command twice):

pip install --upgrade --force-reinstall yomitandic

Usage

Here's how you can use YomitanDic to create dictionary entries:

Creating a Dictionary

First, create a Dictionary object to hold your entries:

from yomitandic import DicEntry, Dictionary, create_html_element

dictionary = Dictionary("Example_Dictionary")

Adding Entries

There are three ways to add entries to a dictionary:

Method 1: Simple Definition

Self explanatory.

entry = DicEntry("踊る", "おどる", definition="To dance", tag="v5r")
dictionary.add_entry(entry)

Method 2: Definition with Link

set_link_content() is a method that allows you to easily add text and a link to an entry without having to know html.

entry = DicEntry("行く", "いく", tag="v5k-s")
entry.set_link_content(
    "行く means 'to go'.", # definition
    "https://ja.wikipedia.org/wiki/行く" # link that goes underneath
)
dictionary.add_entry(entry)

Method 3: Custom HTML Elements

For more control over the entry's content, you can manually add HTML elements using the create_html_element() function:

entry = DicEntry("食べる", "たべる", tag="v5r")

definition_element = create_html_element("ul", [ # A bullet point list containing one bullet point with text "To eat"
    create_html_element("li", "To eat")
])
link_element = create_html_element("ul", [ # A bullet point list containing one bullet point with hyperlink text "View on Jisho"
    create_html_element("li", [
        create_html_element("a", "View on Jisho", href="https://jisho.org/word/食べる")
    ])
], style={"listStyleType": "\"\""})

entry.add_element(definition_element)
entry.add_element(link_element)

dictionary.add_entry(entry)

Exporting and Zipping

After you've added all the entries to your dictionary, you can export it to json and zip into a folder:

dictionary.export()  # Write all entries to word_bank.json files inside a folder with the name of the dictionary
dictionary.zip()     # Zip the folder

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

yomitan-dic's People

Contributors

hopto-dot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

yomitan-dic's Issues

Wrong(?) positioning of "tag" value in term_bank.json file

Hi, i noticed that the tag value is incorrectly placed at position [2] inside the term_bank file. The correct position should be [3]. If placed in [2] conjugations wont work.

I solved by switching line 24 and 25 in the yomitandic.py file. I don't know if this is a correct solution but works for me.

        return [
            self.word,
            self.reading,
            self.tag,
            "",
            0,
            content,
            0,
            ""
        ]
        return [
            self.word,
            self.reading,
            "",
            self.tag,
            0,
            content,
            0,
            ""
        ]
Before After
image image image image

Adding images

Hi I'd like to add images to a dictionary with your program. I see that Marv's npm version of the yomitan dictionary builder has that option but is it already possible to add images with your program or how would I go about doing that? Any help is appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.