Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional info to dictionary entries and use standard arg parsing #18

Merged
merged 10 commits into from Jan 29, 2022

Conversation

mymro
Copy link
Contributor

@mymro mymro commented Jan 4, 2022

This pull request resolves #14 and uses the standard arg parser.

Cleanup


Update README


Fix bug in JMnedict parsing


Update Makefile


Fix Bug in minifying index


Fix Bug in minifying index


Fix Bug in minifying index


Update README


Rename
@mymro mymro changed the title Add additional info to dictionary entries and unse standard arg parsing Add additional info to dictionary entries and use standard arg parsing Jan 4, 2022
@mymro
Copy link
Contributor Author

mymro commented Jan 19, 2022

@jrfonseca When will you merge the commits?

Copy link
Collaborator

@jrfonseca jrfonseca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise looks good AFACT.

Sorry for the delay. I've been really busy with some personal stuff, and will continue to be, until past Easter.

@@ -20,9 +20,6 @@ then processed with ImageMagick's
`mogrify -colorspace gray -level 0%,111.11% -define PNG:compression-level=9`
to look like E-Ink display.
-->

![Inflection lookup screenshot](screenshots/infl.png)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep an example of inflection.

@@ -237,14 +241,14 @@ def write_index(entries, dictionary_name, title, stream, respect_re_restr=True,
entry.sentences.sort(reverse=True, key = lambda sentence: sentence.good_sentence)
for sentence in entry.sentences:
stream.write(' <div class="sen">\n')
stream.write(' <span>' + sentence.japanese + '</span>\n')
stream.write(f" <span>{sentence.japanese}</span>\n")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f-strings is great, but for future reference, I'd prefer if we standardized on single quotes ' strings, as this makes it easier to emit " in the generated XML/HTML

dictionary.py Outdated
stream.write('<?xml version="1.0" encoding="utf-8"?>\n')
stream.write('<package unique-identifier="uid">\n')
stream.write(' <metadata>\n')
stream.write(' <dc-metadata xmlns:dc="http://purl.org/metadata/dublin_core">\n')
stream.write(' <dc:Identifier id="uid">%s</dc:Identifier>\n' %(hex(hash(title)).split('x')[1]))
stream.write(' <dc:Title><h2>%s</h2></dc:Title>\n' %title)
stream.write(f" <dc:Identifier id=\"uid\">{hex(hash(title)).split('x')[1]}</dc:Identifier>\n")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, here, using f'...' would avoid escaping the single quote.

jmdict.py Outdated

arg_parser = argparse.ArgumentParser(description='Build the JMdict or JMnedict for Kindle', formatter_class=argparse.RawTextHelpFormatter)
arg_parser.add_argument('-s', '--sentences'
,action='store'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to nitpick, but commas like this look awkward to me.

I'm starting to think it might be better to start using some sort of automated Python code formatting tool to ensure code is consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrfonseca How would you prefer them?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing commas. https://www.python.org/dev/peps/pep-0008/#when-to-use-trailing-commas

Honestly, I think the easiest thing to do is to use an automated tool to format like https://www.python.org/dev/peps/pep-0008/ . I know there are a few, and I even recall to use one a couple of years ago, but I forgot which.

@mymro
Copy link
Contributor Author

mymro commented Jan 20, 2022

@jrfonseca I will probably update this commit over the weekend

Fix auto format in action


Fix auto format in action


Fix auto format in action


Fix auto format in action


a


a


Change Actions for pull_request_target


a


a


a
@mymro mymro force-pushed the master branch 2 times, most recently from 6320a8e to ad25d56 Compare January 22, 2022 08:48
@mymro
Copy link
Contributor Author

mymro commented Jan 22, 2022

@jrfonseca The code will now be checked for being correctly formatted with black in each push or pull request. In the README there is a section that explains how to automatically let black format the source files.

I have also included the screenshot with an inflection and put the images on two lines in order for them not to take up so much space.

As soon as this pull request is merged, I will check the whole repository for compliance with black and then push eventual changes.

@mymro
Copy link
Contributor Author

mymro commented Jan 29, 2022

@jrfonseca Could you please merge the pull request.

@jrfonseca jrfonseca merged commit d817ffb into jmdict-kindle:master Jan 29, 2022
@jrfonseca
Copy link
Collaborator

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

include notes
2 participants