Giter Site home page Giter Site logo

anker's Introduction

Readme

Anker

Prerequisites

Autocompletion

Source this in .zshrc or run it once and store it to speed up the evaluation. Replace zsh for bash.

eval "$(_ANKER_COMPLETE=zsh_source anker)"

Plugins

Cards

They are a blueprint how to generate flashcards. They take inputs from a fetcher and specify how to transform the input possibly via creators and how to map them to fields.

Cards have to inherit from MetaCard from anker.meta and must implement a prepare method that prepares the input. This method will be called for every input.

Inheritance may be used to have a generic language card that abstracts certain things like translating for multiple languages.

class Card(MetaCard):
    deck_name = "Default"
    model_name = "English"
    tags = ["english::idioms"]

    _field_Family = "Idioms"

    def prepare(self, inputs, **kwds):
        self.idiom, self.meaning, self.example = inputs

    @field
    def English(self):
        return self.idiom

    @field
    def EE(self):
        return self.meaning
deck_name
The Anki deck the cards will be put in
model_name
The Anki model the cars will use.
tags
What Anki tags to add to the note.
_field_XXX
Static values for the field named XXX
@field
Decorate a method. The return value will be used for the field with the same name as the method.
prepare()
Prepares the input for use.
hook()
Some creators need to be updated each round.

Fetcher

Fetcher generate inputs for the card templates. Examples

  • Scrape English idioms from a website
  • Generate all multiplication calculations from with arguments from 1..100

Put your modules in anker.fetcher. You need to expose a Fetcher object that is iterable.

Functional example

Fetcher = (x for x in range(100))

Object oriented skeleton

class Fetcher:
    def __iter__(self):
        for page in self.iter_pages():
            yield from self.consume_soup(page)
    # Ellipsis

Implementing __getitem__ and __len__ also works.

Creators

Creators take an input and create some content for it. Examples

  • Translate a word with Google translate
  • Find the URL to an image that is symbolic for a word.
  • Find context for a word out of a book

Formatters

Formatters provide utility decorators to beautify the outputs.

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.