sobjornstad / ankilpcg Goto Github PK
View Code? Open in Web Editor NEWAddon for dae/anki for studying lyrics and poetry
Home Page: https://ankilpcg.readthedocs.io/en/latest/index.html
License: GNU General Public License v3.0
Addon for dae/anki for studying lyrics and poetry
Home Page: https://ankilpcg.readthedocs.io/en/latest/index.html
License: GNU General Public License v3.0
I think that will be a little more readable.
LPCG doesn't seem to be made specifically for this use however seems to be the addon which would come the closest to supporting this.
Take for instance these three latin sentences with dutch translations:
Latin | Dutch |
---|---|
Ille ego qui fuerim, tenerorum lusor amorum, | Ik die zo bekend ben, wat voor iemand ik geweest ben, die speelse dichter van |
quem legis, ut noris, accipe posteritas. | tedere verliefdheden, die u leest, verneem [dat], nageslacht, opdat u het weet |
Sulmo mihi patria est, gelidis uberrimus undis, | Sulmo is mijn vaderland, zeer rijk aan koele stromen, |
Wat I would like to see is some context lines in latin and for instance a card which asks about the translation of the second latin sentence with context lines before and after. Is there any way to do this? The addon almost seems to be able to do it but some features miss. Anyways thanks for the nice plugin @sobjornstad
For people who happen upon this Git-repo. =)
First, thank you for this addon, I needed something to organise my revision process.
I'd like to offer an idea.
When memorising something like T.S.Eliot I find that the lines in the poem aren't such a useful unit for dividing the poem.
Instead I like to set all the LPCG values to 1 and then run the poem through this script, which breaks it into sentences and puts each sentence into a separate line. I'm a bit torn as to whether I should count a semicolon as the end of a sentence.
You need to put the poem in poem.txt
Also, I brought in nltk for this, which is a bit overkill, but I already had it installed.
from nltk.tokenize.punkt import PunktSentenceTokenizer, PunktLanguageVars
class MyPunktLanguageVars(PunktLanguageVars):
sent_end_chars = ('.', '?', '!')
tokenizer = PunktSentenceTokenizer(lang_vars = MyPunktLanguageVars())
# take a poem and split it into sentences and make each sentence a line
def poem_to_sentence_lines(text):
text = text.strip()
# remove all single newlines, leave double newlines
text = text.replace('\n\n', 'placeholder')
text = text.replace('\n', ' ')
text = text.replace('placeholder', '\n\n')
sentences = tokenizer.tokenize(text)
return '\n'.join(sentences)
# read the text from a file called poem.txt
def read_poem():
with open('poem.txt', 'r') as f:
return f.read()
poem = read_poem()
poem = poem_to_sentence_lines(poem)
with open('poem_out.txt', 'w') as f:
f.write(poem)
I want to give suggestion, beyond thanking you for this app.
Certain kinds of music and poem have too short lines, and it would be more efficient to recall them in groups (of two lines, for example) instead of creating a lot of cards recalling just a few word.
If you could set this possibility in you add-on, just as we can already choose the number of context lines, it would be great!
Hello,
Using AnkiLPCG with Python 2.7. I can drag and drop the input file, specify the title and tags, however I would then end up with the following error:
C:\Users\Fabien\Downloads\AnkiLPCG-master\AnkiLPCG-master>lpcg.py
Lyrics/Poetry Cloze Generator v0.9.0
Copyright 2013 Soren Bjornstad; see COPYING for details.
Input File: Drag and drop the input file you wish to use onto this window.
Title: This will be used to prompt you for the first line of the text.
Tags: This will be fed to Anki as the Tags field of each card.
For further help, see the README.
Input File: "D:\Dropbox\LANGUAGES\EN American English\English Pronunciation\Mode
ls\Poems\Fire and Ice.txt"
Title: Fire and Ice
Tags (optional): FireAndIce
Traceback (most recent call last):
File "C:\Users\Fabien\Downloads\AnkiLPCG-master\AnkiLPCG-master\lpcg.py", line
163, in <module>
main()
File "C:\Users\Fabien\Downloads\AnkiLPCG-master\AnkiLPCG-master\lpcg.py", line
112, in main
lyrics_file = open(input_file)
IOError: [Errno 22] invalid mode ('r') or filename: '"D:\\Dropbox\\LANGUAGES\\EN
American English\\English Pronunciation\\Models\\Poems\\Fire and Ice.txt"'
I've fixed it by removing whitespaces from the input file's name and by moving it to a different directory.
I would suggest either automatically adding double-quotes around the path or putting a warning about paths inside of the readme.
I hope it helps somewhat.
By the way, thanks for the script, I've started playing with some poems I want to commit to memory and this is great stuff!
Fabien
Add support for a new field for the author.
Traceback (most recent call last):
File "/Users/David/Library/Application Support/Anki2/addons/LPCG.py", line 170, in open_dialog
dialog = LPCGDialog(aqt.mw)
File "/Users/David/Library/Application Support/Anki2/addons/LPCG.py", line 44, in init
self.form = lpcgform.Ui_Dialog()
AttributeError: 'module' object has no attribute 'Ui_Dialog'
Sometimes, especially when the spelling of certain rare words is hard, it would be neat to be able to have a type-in like card instead of simply revealing the answer. One way to implement this would be to add an option during the generation of the notes to make the whole poem "type-in", and to have a second note-type roughly equal to the current one, but with type-in in the template.
I currently do this by hand, and the only limitation I see is that it's impossible to have multiple lines with type-in.
Currently the script treats blank lines line any other line, resulting in bad cards which are not easy to correct.
It should probably skip the lines, and optionally add marks like "(E)". Of course, with the current UI, it should not ask the user about it.
I really like the addon and use it to memorize texts. One thing I don't like so much (that is inherent by the way it anki and the addon works) is that during review I constantly have to switch between the different texts. This can get in the way when trying to memorize many different texts (especially if you you have texts with similar but still different passages).
Any thoughts on that issue?
One workaround could maybe be to set a tag for each Text (poem,...) and then create custom study decks for each tag. If I select the parent deck for studying then the sub decks (custom study decks) would get reviewed once at a time if I recall correctly. I already have a lot of decks already however and the texts get more and more...
This addon has been updated today in anki without new commits. Are you using a different repo or have you been hacked?
Hey Soren,
I just started to use Anki and stumbled upon your script. I did install the note type and have been trying to run the script on a poem and a testfile. The result has been the same:
Title: testtext
Tags (optional): testtext
Traceback (most recent call last):
File "./lpcg.py", line 173, in <module>
main()
File "./lpcg.py", line 122, in main
lyrics_file = open(input_file)
TypeError: coercing to Unicode: need string or buffer, NoneType found
What's the problem here? I tried to make sure, my files are encoded in UTF-8. Any ideas? (I'm on a Mac and use Python 2.7.5)
Add a basic/cloze note, in addition to the LPCG notes, when importing a poem which matches Author with Title.
eg:
# Front
<span class="cloze">[...]</span> wrote {{Title}}.
# Back
{{Author}} wrote {{Title}}.
Follow-up to #20.
Believe it or not this addon is used for Quran memorization.
Some of the verses of the Quran is really long for Ankifying. One way to use this addon then artificially cut the lines to have say 5 lines out of a single verse. This works, but it makes the task of automatically generating the cards much more tiring as you can imagine. It also messes up with verse ordering, and makes it easy to forget where does the actual verse is ending.
I and many "quranic aid" deck users would be really interested if there was a way to cut long lines into smaller ones naturally, so a reverse of line combining feature.
Thanks for all the effort! I did not know how to use Github before, hence my really late post.
It's always nice to be able to note down where you got a poem, either so you can tell what was telling you the wrong words to the poem or so you can cite where you got it from or any of many other reasons.
Bonus/alternative feature: some creative way for users to easily add fields themselves as needed
Hi, this is probably my fault some how but I had an error message when generating cards so I'm posting it here
Debug info:
Anki 2.1.35 (84dcaa86) Python 3.8.0 Qt 5.14.2 PyQt 5.14.2
Platform: Mac 10.14.6
Flags: frz=True ao=True sv=1
Add-ons, last update check: 2020-11-15 14:21:47
Add-ons possibly involved: LPCG LyricsPoetry Cloze Generator
Caught exception:
Traceback (most recent call last):
File "/Users/allen/Library/Application Support/Anki2/addons21/2084557901/lpcg_dialog.py", line 48, in accept
if self.mw.col.findNotes(f'"note:{models.LpcgOne.name}" "Title:{title}"'): # pylint: disable=no-member
File "anki/collection.py", line 453, in find_notes
File "anki/rsbackend_gen.py", line 88, in search_notes
File "anki/rsbackend.py", line 267, in _run_command
anki.rsbackend.InvalidInput: Invalid search - please check for typing mistakes.
Hi, I've been using this add-on only fairly recently to learn my poems as part of my English course. Adding one poem seems to be fine, all is working. However, the second I add another poem or attempt to edit the first one to allow to 'type in' my response, an error response appears and I can't proceed without multiple error windows appearing at once.
I attempted to sift through add-ons i was previously using to see if they were causing the problem, but it seems to be this one.
It's such a shame! I really was looking forward to using this for my study.
I'm currently using the Anki software for MacOS with Apple Silicon (if that helps) :)
Thanks for developing the awesome addon.
But if I want to write the line,like "type" class,how can i do that?
This happened when I had a blank line and then a comment at the end of the entry box.
I was just passing through your repo and wondered if you had considered adding LilyPad support. Especially with the anki integration. I don't know if this would break your script but you could, as far as I can tell, not change anything and just make the lyrics
Do re me [lilypond]c d e[/lilypond]
fa sol la [lilypond]f g a[/lilypond]
and it would work perfectly (maybe). I just think it would be a great connection between two useful services
Hello,
Using the latest version of Python, I could not get AnkiLPCG to work.
As it turns out, this is because of the new behavior of the print function in Python 3+ (now an actual function, not a language construct anymore). See this thread: http://stackoverflow.com/questions/826948/syntax-error-on-print-with-python-3
After fixing the function for myself inside of the script, however, executing the script would result in a file not found error (sorry I don't have a copy of this as I've downgraded Python in the meantime). It happened both when running the script from Windows (and then I wouldn't be offered the chance to specify the Input File, Title and Tags) and from the command-line.
Thanks for reading!
Fabien
Hi,
Sometimes I need to read the full poem for context when I make a mistake, or just to ground myself with surrounding lines. Would it be possible to generate cards with a third field that can be shown on the answer side with the full poem? (Possibly like overlapping cloze, where there is a link that can be used to expand the field so it is not shown by default)
Hi,
I wonder if it is possible to set related cards for one poem to bury related reviews.
E.g., the poem is divided into 4 pieces, A B C D. Sometimes I'll see B C ___ and A B ___ in a short time, reviewing the second card will be meaningless and may lead to a longer recall time in mistake.
Per user suggestion via email:
[W]ith night mode enabled, the answered card has a dark blue text which is barely visible, is there an option to change the colour?
We can add this to the styling section to make things look decent in both modes:
.nightMode .cloze {
filter: invert: 100%;
-webkit-filter: invert(100%);
}
It should be safe to inject this even into existing note types on startup, as long as no existing .nightMode
directives have been added to the note type.
Side note, it looks like the official cloze template is really hard to read too! Maybe we'll be one step ahead of core. :-)
I am new to Anki as well as LPCG, so perhaps I am doing something wrong.
Using Anki with some music training decks, such as the "Joe's Ear" deck, everything works properly. But when I loaded LPCG and attempted to add a simple poem I got the error shown below and in the attached screen shot.
-Peter Shenkin.
--
Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site.
Debug info:
Anki 2.1.13 (3ba55990) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Mac 10.14.6
Flags: frz=True ao=True sv=1
Add-ons possibly involved: LPCG LyricsPoetry Cloze Generator
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.