lexical note hlt · adv-nlp

Create a new deck

!pip install genanki
Collecting genanki
  Downloading genanki-0.13.1-py3-none-any.whl.metadata (7.5 kB)
Collecting cached-property (from genanki)
  Downloading cached_property-2.0.1-py3-none-any.whl.metadata (10 kB)
Requirement already satisfied: frozendict in /Users/krisstallenberg/anaconda3/lib/python3.12/site-packages (from genanki) (2.4.2)
Collecting chevron (from genanki)
  Using cached chevron-0.14.0-py3-none-any.whl.metadata (4.9 kB)
Requirement already satisfied: pyyaml in /Users/krisstallenberg/anaconda3/lib/python3.12/site-packages (from genanki) (6.0.1)
Downloading genanki-0.13.1-py3-none-any.whl (16 kB)
Downloading cached_property-2.0.1-py3-none-any.whl (7.4 kB)
Using cached chevron-0.14.0-py3-none-any.whl (11 kB)
Installing collected packages: chevron, cached-property, genanki
Successfully installed cached-property-2.0.1 chevron-0.14.0 genanki-0.13.1
import genanki
# Create a new deck
deck = genanki.Deck(
    2059400110,
    'Example Deck')

# Create a model with the name "SimpleModel"
model = genanki.Model(
    1607392319,
    'SimpleModel',
    fields=[
        {'name': 'Question'},
        {'name': 'Answer'},
    ],
    templates=[
        {
            'name': 'Card 1',
            'qfmt': '{{Question}}',
            'afmt': '{{FrontSide}}<hr id="answer">{{Answer}}',
        },
    ])

# Add the model to the deck
deck.add_model(model)

# Create a new note
note = genanki.Note(
    model=model,
    fields=['Capital of Argentina', 'Buenos Aires'])

# Add the note to the deck
deck.add_note(note)

# Create a package
genanki.Package(deck).write_to_file('example.apkg')
print("Deck created successfully!")
Deck created successfully!
# Load the deck from the file
deck = genanki.Deck('example.apkg')
print("Deck loaded!")

# Get the first note from the deck
print(deck.notes)
Deck loaded!
[]