Giter VIP home page Giter VIP logo

fuzhulun's Introduction

banner

辅助轮 (FuZhuLun)

For English speakers who wish to learn Mandarin Chinese, FuZhuLun is a Python script that formats Mandarin Chinese text and augments new words with Pinyin and English.

This prototype uses a text file to generate a print-friendly HTML page designed to fit A4 or US letter-sized paper. Each paragraph is printed in a large, easy-to-read font, and under each paragraph is a table of new words in Chinese, Pinyin, and English.

If crafting regular expressions is your thing, it is also possible to configure the script look for "chapters," checkpoints where all words will be reviewed again.

Directions

  1. Install Python with BeautifulSoup and Pinyin

  2. Create or find a file that contains Chinese text. Note that other languages will be printed in large font too, including English, Spanish, CSS, and HTML.

  3. The first lines of the script allow users to configure the layout. Replace INPUT_FILE with the relative path to your input and OUTPUT_FILE with the desired output path.

NEW_CHAPTER_PATTERN can either be None or a regular expression (in the form re.compile(r'<insert_pattern_here>', re.DOTALL)). Word definitions will only be printed once per chapter, immediately after the first paragraph in which it's used. (None will only print each definition once.)

INPUT_FILE  = 'Your text file here'
OUTPUT_FILE = 'A new HTML file will go here'
ENCODING = 'utf-8'
NEW_CHAPTER_PATTERN = None
NEW_PARAGRAPH_PATTERN = re.compile(r'(?<=\n\n)(.*?)\n\n', re.DOTALL)
# Use the following pattern to split the text into sentences
# NEW_PARAGRAPH_PATTERN = re.compile(r'(?<=\n\n)(.*?[。!?])(?=\n\n)', re.DOTALL)


# Customize the document style and formatting here
CSS_STYLE = '''
...
HTML stylesheet here
...
'''
  1. Run the script: python reformat.py. An HTML file should have been generated.

  2. Open the new HTML file. It's path is the same once set in OUTPUT_FILE

  3. Print the generated HTML document. For best viewing experience online, consider printing as a PDF.

Contributing

The journey to learning Mandarin can be hard and very rewarding. I wish you the best of luck and hope you've found this tool helpful for your studies.

Please use this script however you see fit. If you believe a change might help someone understand/use the script later, please don't hesitate to submit a pull request here. Bug reports are welcome too.

Sample

The following is an excerpt generated from Sun Tzu's Art of War, generously provided on Wikisource under the Creative Commons Attribution-ShareAlike License

picture 1 picture 2 picture 3

fuzhulun's People

Contributors

m516 avatar

Watchers

 avatar

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.