Giter VIP home page Giter VIP logo

mnemocards's Introduction

Mnemocards logo

Mnemocards CI pipeline status Mnemocards coverage status Mnemocards issues Mnemocards contributors Mnemocards total downloads Mnemocards downloads per month
In addition to helping you memorise, this code helps you do other things that I don't remember...


๐Ÿ“š Documentation: https://guiferviz.com/mnemocards

โŒจ๏ธ Source Code: https://github.com/guiferviz/mnemocards


Mnemocards generated vocabulary card

๐Ÿค” What is this?

Mnemocards is a Python package originally intended for creating Anki flashcards from text files. It allows users to define a series of steps to read flashcards from any source, transform them and export them to different formats such as Anki APKG packages.

Mnemocards is designed to be fully extensible, which means that users can create their own tasks and customize the card generation process to their specific needs. Indeed, Mnemocards has the versatility to be used for purposes beyond generating Anki decks.

๐Ÿท๏ธ Features

  • Generate Anki APKG packages that you can later import into the Anki app.
  • Auto generate pronunciations from the words that you are learning in any language supported by Google Translator.
  • Generate flashcards from text files that can be stored in Git repositories. This brings several positive things:
    • Keep track of changes.
    • Edit cards using your favourite text editor. I โค๏ธ VIM.
    • Easily share and collaborate with others. If you know how to work with Git you can create forks and pull requests to existing repositories.
  • Fully extensible architecture that allows you to define custom transformations on a list of notes.
    • Possibility to implement another way of exporting flashcards to other existing flashcards apps. Contributions are welcome.
    • Possibility to create search indexes, analyze your collection of cards, create visualizations, clustering, analyze how the cards relate to each other... Contributions are welcome.

โš™๏ธ Installation

To get started with Mnemocards, you'll need to have Python >= 3.10 installed on your computer. Then, you can install Mnemocards using pip:

$ pip install --pre mnemocards

You can check that the installation went well by executing the following command:

$ mnemocards --version
โ•”โ•ฆโ•—โ•”โ•—โ•”โ•”โ•โ•—โ•”โ•ฆโ•—โ•”โ•โ•—โ”Œโ”€โ”โ”Œโ”€โ”โ”ฌโ”€โ”โ”Œโ”ฌโ”โ”Œโ”€โ”
โ•‘โ•‘โ•‘โ•‘โ•‘โ•‘โ•‘โ•ฃ โ•‘โ•‘โ•‘โ•‘ โ•‘โ”‚  โ”œโ”€โ”คโ”œโ”ฌโ”˜ โ”‚โ”‚โ””โ”€โ”
โ•ฉ โ•ฉโ•โ•šโ•โ•šโ•โ•โ•ฉ โ•ฉโ•šโ•โ•โ””โ”€โ”˜โ”ด โ”ดโ”ดโ””โ”€โ”€โ”ดโ”˜โ””โ”€โ”˜ X.Y.Z
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ <A super mega funny joke here> โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

If the joke made you laugh you can continue with this tutorial, otherwise this program is not for you and you should consider other alternatives.

โ“How it works?

Once you have Mnemocards installed, you can start creating your own flashcards. Let's start creating our own vocabulary Anki cards.

Imagine you are learning Spanish and you have a list of vocabulary like this:

English Spanish
Hello Hola
Bye Adiรณs

If you want to use Mnemocards to generate Anki cards for those words the first thing you need to do is to create a CSV file like the following:

your_language_word,language_you_learn_word,id
Hello,Hola,9a6c9728-7f86-4e3f-9dec-a2f804bd0a76
Bye,Adiรณs,e600a85a-8a6b-4449-a188-f7401dc69d6b

A CSV file is a text file that represents a table. The first line is the header of the table, after that header line we have one line per row. Each column is separated from the other with a column. CSV stands for Comma-Separated Values.

The first column contains the word in your native language, in this case English. The second row is the word in the language you are learning, Spanish. The last column is a randomly generated ID.

!!! question "Why do we need an ID?"

IDs are used to uniquely identify a note in Anki. We can use the Spanish
word as an ID, but if you start studing a card and you want to make an edit
later the card will be considered as a complete new one, loosing your
progress.

For example, imagine you write *Adios* and after several days of study you
realise that your miss the accent. If you chage *Adios* to *Adiรณs* the
ID of that note will be different. To avoid this kind of problems I decided
to include an ID column.

Mnemocards uses a configuration file named mnemocards.yaml to define the steps that will be used to process our flashcards. In this file, you can specify the tasks that you want to use, the order in which they will be executed, and any necessary parameters.

Here is an example of a simple configuration file that reads in a CSV file containing vocabulary data, and then generates an Anki APKG package:

steps:
  # Read a CSV file with our spanish vocabulary.
  - type: ReadCsv
    path: vocabulary.csv
  # Tag the generated notes and assign them to an Anki deck.
  - type: mnemocards_anki.Configure
    tags: spanish, languages
    deck:
      name: Spanish
      id: 429d2604-ca8a-4c0a-9b03-38d1df5b9af7
    note_type: mnemocards_anki.VocabularyNoteType
  # Pronounce the spanish words using Google Translator.
  - type: mnemocards_anki.Pronounce
    language: es
    attribute_to_pronounce: language_you_learn_word
  # Save the Anki package.
  - type: mnemocards_anki.Package
  # Show the generated tasks in the terminal.
  # Do not print the note id, the note_type and the deck to avoid cluttering the terminal.
  - type: Print
    ignore_regex: id|note_type|deck
  # Show some stats of the generation process.
  - type: Stats

You can run the configuration file using the following command:

$ mnemocards run mnemocards.yml

This will execute the steps in the configuration file, and will generate an Anki package named out.apkg by default. The generated file is in the same directory as your mnemocards.yaml.

If you import the apkg file to Anki you can start studying Spanish:

Mnemocards generated vocabulary card

๐Ÿค“ What is next?

If you have come this far, it is because you may have found this project interesting. Consider visiting the documentation, in particular the examples section to learn more.

As mentioned above, Mnemocards is fully extensible, so any data source you miss or any processing or analysis you want to do on your cards is more than welcome. Feel free to post your idea to start a discussion. Do not worry if you do not know how to program, there may be someone who can do it for you.

Enjoy learning!!!

mnemocards's People

Contributors

andoresu47 avatar dependabot[bot] avatar guiferviz avatar otter-man avatar planelles20 avatar sudolife avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mnemocards's Issues

mnemocards doesn't work after installation due to idna version conflict and changes in anki

Currently, mnemocards don't work because it has version conflict in the requirements and updates in anki.

Both httpx and requests require idna<3.* (psf/requests#5710) but idna==3.3 is installed via some other dependencies.

Anki changed one of the module names in the latest version, removing capitalization (from Collections to collections)
So mnemocards crashes if the previous version conflict is resolved.

This issue was open for visibility.
Solutions are provided within my pull request with a new feature #16

Script /docker/run.sh doesn't work.

Script for docker doesn't work, because docker image doesn't have "latest" tag.

$ sudo ./run.sh
Unable to find image 'guiferviz/mnemocards:latest' locally
docker: Error response from daemon: manifest for guiferviz/mnemocards:latest not found: manifest unknown: manifest unknown.

You also can't pull image from docker hub with docker pull guiferviz/mnemocards for the same reason.

Current workaround:
Rewrite line guiferviz/mnemocards in run.sh to guiferviz/mnemocards:v0.1.3 the script starts working.

Solution:
Add image with latest tag https://hub.docker.com/r/guiferviz/mnemocards/tags

Autogenerated cards misplace translations into wrong columns

Hello, I'm trying to autogenerate cards from English to French. I've set the lang field in cards_config.json

					"id": "29b15499-d339-4b1c-8b31-2d7466a29a2b",
					"name": "French Vocabulary - English to French",
					"src": 
					[
						{
							"type": "autogenerate",
							"file": "words.txt",
							"card_color": "#33AA33",
							"show_tags": true,
							"card_properties": 
							{
							"tags": ["french", "vocabulary", "autogenerated"]
							},
							"header": false,
							"pronunciation_in_reverse": false,
							"lang": 
							{
								"original": "en",
								"translation": "fr"
							},
							"one_translation": false,
							"audio": true
						}         
					]

The words.txt file contains three words in English

car
January
Monday

The translations generated by mnemocards generate and mnemocards maketsv place the generated translations in wrong columns:

ID	YourLanguageWord	YourLanguageExplanation	LanguageYouLearnWord	LanguageYouLearnPronunciation	LanguageYouLearnExplanation	Tags
0c452564-88b7-c86e-8906-bdc1d505d5cd	janvier		January	หˆjanyษ™หŒwerฤ“	<div class="definitions"><div class="speechpart">Nom</div><div class="line_1">the first month of the year, in the northern hemisphere usually considered the second month of winter.</div><div class="line_2">Sophie was two in January</div></div>	
1d686100-a3c0-c2c2-1d12-663c8e92706e	auto	<div class="synonyms"><div class="speechpart">Nom</div><div class="line_1">voiture</div><div class="line_2">['car', 'vehicle', 'carriage', 'coach', 'wagon', 'motor']</div><div class="line_1">car</div><div class="line_2">['car', 'bus', 'motor']</div><div class="line_1">wagon</div><div class="line_2">['car', 'wagon', 'coach', 'waggon', 'waggonload']</div></div>	car	kรคr	<div class="definitions"><div class="speechpart">Nom</div><div class="line_1">a four-wheeled road vehicle that is powered by an engine and is able to carry a small number of people.</div><div class="line_2">she drove up in a car</div></div>	
3c672ad7-8386-4ba3-29f9-1a0c5ca17138	Lundi	<div class="synonyms"><div class="speechpart">Nom</div><div class="line_1">lundi</div><div class="line_2">['Monday']</div><div class="line_1">le lundi</div><div class="line_2">['Monday']</div></div>	Monday	หˆmษ™ndฤ	<div class="definitions"><div class="speechpart">Nom</div><div class="line_1">the day of the week before Tuesday and following Sunday.</div><div class="line_2">I saw him on Monday</div></div>	

As you can see, the words contained in YourLanguageWord are in French, when they are supposed to be in English. It seems to be that this is opposite of intended behavior. The field YourLanguageWord is supposed to be "The word you want to learn but in your mother tongue or in a known language."

Has anyone encountered this issue?

Tags appear in content of generated markdown cards

When generating the example markdown cards in `examples/computer_science' I see the tags in the content of card like this:

Screen Shot 2020-04-29 at 13 35 18

This does not match the screenshots in the Readme.

It seems like this line is combining this information which is then added to the content:

header = "*Tags: " + ", ".join(note_tags) + "*\n" + header

I changed this line to

header = "" + header

and that generated what I expected.

Does the expression type support audio?

Configuration similar to the audio settings of vocabulary type would be nice. I tried adding copy the settings with no success.

{
    "packages": [
        {
            "name": "english",
            "decks": [
                {
                    "id": "b698a07e-70eb-474b-82cb-f244a608b21e",
                    "name": "English",
                    "src": [
                        {
                            "type": "expression",
                            "file": "expressions.tsv",
                            "header": true,
                            "card_color": "#AA3333",
                            "card_properties": {
                                "tags": ["english", "expressions"]
                            }
                        }
                    ],
                    "audio": {
                        "lang": "en",
                        "media_dir": "./media"
                    }
                }
            ]
        }
    ]
}

Use Poetry

Right now the installation process is a bit complicated due to the use of a custom version of Genanki. Using Poetry as package manager may make things easier, it would be nice to give it a try.

Autogenerated cards put the card translation into the explanation field

As you can see in the screenshot, on Google Translate the box under the translated word features words in both languages.

image

Autogenerating fetchs the entire box, resulting in both translations appearing in the explanatory field.
image

image

YourLanguageExplanation field should be purged of all references to the foreign language, else it is liable that the word you are supposed to translate will appear there.

Error: "The 'None' distribution was not found and is required by mnemocards"

Was super excited to use your add-on but couldn't get it to work.

After installing it this is the error that I see.

โžœ  mnemocards git:(master) โœ— mnemocards
Traceback (most recent call last):
  File "/Users/jyrodgers/.pyenv/versions/3.7.3/bin/mnemocards", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/Users/jyrodgers/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3191, in <module>
    @_call_aside
  File "/Users/jyrodgers/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3175, in _call_aside
    f(*args, **kwargs)
  File "/Users/jyrodgers/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3204, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/Users/jyrodgers/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/Users/jyrodgers/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/Users/jyrodgers/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'None' distribution was not found and is required by mnemocards

I'm running Python 3.7.3 and pip 20.1.

Thank you for any help that you can provide.

Improve way of reading files

It would be great to read a cards_config file in any format, not just JSON. Code must search for cards_config.* in any format and try to convert the file into a dictionary.

Also, instead of using only TSVs, we can accept CSVs, JSONs, *.cards or any other format. Code must expect a dictionary as output, don't care about the format.
Doing this allow us to remove ugly thinks like:

note_id, ylw, yle, lylw, lylp, lyle, row_tags = row

that is forcing users to have exactly the same order in their files.

Mnemocards Logo

I think this library needs a nice logo. I'm still not sure what it could be and even if I knew, I don't have the artistic skills to be able to make it happen.

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.