Multiple Deletions using Cloze Deletion tool

367 views
Skip to first unread message

Garret L

unread,
Jun 9, 2016, 10:33:04 AM6/9/16
to mnemosyne-proj-users
Hi, I'm new to this forum, so this may have already been mentioned, but is there a way to make multiple parts of a single card hidden using cloze deletion? 

Peter Bienstman

unread,
Jun 9, 2016, 10:34:37 AM6/9/16
to mnemosyne-...@googlegroups.com

Sure! Just try e.g.

 

Bla bla [cloze 1] blab la [cloze 2].

 

Peter

 

 

--
You received this message because you are subscribed to the Google Groups "mnemosyne-proj-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mnemosyne-proj-u...@googlegroups.com.
To post to this group, send email to mnemosyne-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mnemosyne-proj-users/0d90d6e0-0408-4d1c-9fff-894ada9362c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Garret L

unread,
Jun 14, 2016, 12:10:07 PM6/14/16
to mnemosyne-proj-users
Okay, but in your example, in one card, [cloze 1] would show up as "[...]" and [close 2] would be visible, and in another card, [cloze 1] would be visible and [cloze 2] would show up as "[...]."

What I'm looking for is this: "bla bla [cloze 1] blab la [cloze 2]." to show up as "bla bla [...] blab la [...]."
-  for both to show up as blanks simultaneously in the same card.

Sorry for the misunderstanding!

On Thursday, June 9, 2016 at 9:34:37 AM UTC-5, Peter Bienstman wrote:

Sure! Just try e.g.

 

Bla bla [cloze 1] blab la [cloze 2].

 

Peter

 

 

From: mnemosyne-...@googlegroups.com [mailto:mnemosyne-...@googlegroups.com] On Behalf Of Garret L
Sent: 09 June 2016 16:19
To: mnemosyne-proj-users <mnemosyne-...@googlegroups.com>
Subject: [mnemosyne-proj-users] Multiple Deletions using Cloze Deletion tool

 

Hi, I'm new to this forum, so this may have already been mentioned, but is there a way to make multiple parts of a single card hidden using cloze deletion? 

--
You received this message because you are subscribed to the Google Groups "mnemosyne-proj-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to mnemosyne-proj-users+unsub...@googlegroups.com.
To post to this group, send email to mnemosyne...@googlegroups.com.

Peter Bienstman

unread,
Jun 15, 2016, 12:46:50 AM6/15/16
to mnemosyne-...@googlegroups.com

Sorry, this is not supported at the moment…

 

Peter

 

From: mnemosyne-...@googlegroups.com [mailto:mnemosyne-...@googlegroups.com] On Behalf Of Garret L
Sent: 14 June 2016 18:10
To: mnemosyne-proj-users <mnemosyne-...@googlegroups.com>
Subject: Re: [mnemosyne-proj-users] Multiple Deletions using Cloze Deletion tool

 

Okay, but in your example, in one card, [cloze 1] would show up as "[...]" and [close 2] would be visible, and in another card, [cloze 1] would be visible and [cloze 2] would show up as "[...]."

 

What I'm looking for is this: "bla bla [cloze 1] blab la [cloze 2]." to show up as "bla bla [...] blab la [...]."

-  for both to show up as blanks simultaneously in the same card.

 

Sorry for the misunderstanding!


On Thursday, June 9, 2016 at 9:34:37 AM UTC-5, Peter Bienstman wrote:

Sure! Just try e.g.

 

Bla bla [cloze 1] blab la [cloze 2].

 

Peter

 

 

From: mnemosyne-...@googlegroups.com [mailto:mnemosyne-...@googlegroups.com] On Behalf Of Garret L
Sent: 09 June 2016 16:19
To: mnemosyne-proj-users <mnemosyne-...@googlegroups.com>
Subject: [mnemosyne-proj-users] Multiple Deletions using Cloze Deletion tool

 

Hi, I'm new to this forum, so this may have already been mentioned, but is there a way to make multiple parts of a single card hidden using cloze deletion? 

--
You received this message because you are subscribed to the Google Groups "mnemosyne-proj-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to mnemosyne-proj-u...@googlegroups.com.

--

You received this message because you are subscribed to the Google Groups "mnemosyne-proj-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to mnemosyne-proj-u...@googlegroups.com.
To post to this group, send email to mnemosyne-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mnemosyne-proj-users/b208fb06-bfee-467a-86d8-0a1a2e37185a%40googlegroups.com.

Garret L

unread,
Jun 15, 2016, 10:28:39 AM6/15/16
to mnemosyne-proj-users
Okay! I know other flashcard programs (Anki) are capable of this feature. I just wanted to know for sure or not if Mnemosyne was!
Thanks!

On Tuesday, June 14, 2016 at 11:46:50 PM UTC-5, Peter Bienstman wrote:

Sorry, this is not supported at the moment…

 

Peter

 

From: mnemosyne-...@googlegroups.com [mailto:mnemosyne-...@googlegroups.com] On Behalf Of Garret L
Sent: 14 June 2016 18:10
To: mnemosyne-proj-users <mnemosyne-...@googlegroups.com>
Subject: Re: [mnemosyne-proj-users] Multiple Deletions using Cloze Deletion tool

 

Okay, but in your example, in one card, [cloze 1] would show up as "[...]" and [close 2] would be visible, and in another card, [cloze 1] would be visible and [cloze 2] would show up as "[...]."

 

What I'm looking for is this: "bla bla [cloze 1] blab la [cloze 2]." to show up as "bla bla [...] blab la [...]."

-  for both to show up as blanks simultaneously in the same card.

 

Sorry for the misunderstanding!


On Thursday, June 9, 2016 at 9:34:37 AM UTC-5, Peter Bienstman wrote:

Sure! Just try e.g.

 

Bla bla [cloze 1] blab la [cloze 2].

 

Peter

 

 

From: mnemosyne-...@googlegroups.com [mailto:mnemosyne-...@googlegroups.com] On Behalf Of Garret L
Sent: 09 June 2016 16:19
To: mnemosyne-proj-users <mnemosyne-...@googlegroups.com>
Subject: [mnemosyne-proj-users] Multiple Deletions using Cloze Deletion tool

 

Hi, I'm new to this forum, so this may have already been mentioned, but is there a way to make multiple parts of a single card hidden using cloze deletion? 

--
You received this message because you are subscribed to the Google Groups "mnemosyne-proj-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to mnemosyne-proj-users+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "mnemosyne-proj-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to mnemosyne-proj-users+unsub...@googlegroups.com.


To post to this group, send email to mnemosyne...@googlegroups.com.

Scott Youngman

unread,
Jun 15, 2016, 11:02:42 AM6/15/16
to mnemosyne-proj-users
Garret, you can achieve what you want by making the card front-to-back, or front-to-back-&-back-to-front instead of a cloze-type card. Enclose the elements to be tested in square brackets (just like in cloze formatting); the question card will show them as grey, italicized brackets with whatever text you included between brackets. (In the examples below, imagine the bracketed parts to be gray italic.)

So if you make the Question card
bla bla [1] bla bla [2]

both bracketed parts will remain bracketed just as entered, and the Answer card could be
1. "answer 1"
2. "answer 2"

The text in the brackets can be an ellipsis or a hint instead of numbers. You can also format the text in the brackets as desired, which overrides the default gray.

If that's unclear, try it on a test card to see what I mean. The important part is NOT to make it a cloze-type, even though you are using square brackets in the question.

Scott

Peter Bienstman

unread,
Jun 15, 2016, 11:38:17 AM6/15/16
to mnemosyne-...@googlegroups.com
Great idea, thanks for suggesting it!

Peter

On 15 June 2016 17:02:42 CEST, Scott Youngman <syo...@gmail.com> wrote:
Garret, you can achieve what you want by making the card front-to-back, or front-to-back-&-back-to-front instead of a cloze-type card. Enclose the elements to be tested in square brackets (just like in cloze formatting); the question card will show them as grey, italicized brackets with whatever text you included between brackets. (In the examples below, imagine the bracketed parts to be gray italic.)

So if you make the Question card
bla bla [1] bla bla [2]

both bracketed parts will remain bracketed just as entered, and the Answer card could be
1. "answer 1"
2. "answer 2"

The text in the brackets can be an ellipsis or a hint instead of numbers. You can also format the text in the brackets as desired, which overrides the default gray.

If that's unclear, try it on a test card to see what I mean. The impo rtant part is NOT to make it a cloze-type, even though you are using square brackets in the question.

Ernesto Sastre

unread,
Jun 26, 2016, 12:12:33 AM6/26/16
to mnemosyne-proj-users

El jueves, 9 de junio de 2016, 11:33:04 (UTC-3), Garret L escribió:
Hi, I'm new to this forum, so this may have already been mentioned, but is there a way to make multiple parts of a single card hidden using cloze deletion? 

I feel you bro, I was actually looking for the same. I gave a glimpse at Peter's cloze.py code, and although it is not that hard to follow I could not set my mind to code a new card type class (Multi-cloze deletion class) that inherited from the cloze class. I have exams next week and I can't afford to spend time on this right now.  I am sure that Peter would be able to perform with great ease some modifications to his own cloze.py code to fit your needs. There is a function in it that does "create sister cards"; maybe discarding it from the code is a first step approach. I will adjunt cloze.py code

#
# cloze.py <Peter.B...@UGent.be>
#

import re

from mnemosyne.libmnemosyne.translator import _
from mnemosyne.libmnemosyne.card import Card
from mnemosyne.libmnemosyne.plugin import Plugin
from mnemosyne.libmnemosyne.card_type import CardType
from mnemosyne.libmnemosyne.fact_view import FactView

cloze_re = re.compile(r"\[(.+?)\]", re.DOTALL)


class Cloze(CardType):

    """CardType to do cloze deletion on a string, e.g. "The political parties in
    the US are the [democrats] and the [republicans]." would give the following
    cards:

    Q:The political parties in the US are the [...] and the republicans.
    A:democrats

    Q:The political parties in the US are the democrats and the [...].
    A:republicans

    Illustration of a CardType which does not use the traditional FactView
    mechanism.

    This is implemented by creating cards which contain extra_data entries
    "cloze" and "index", containing e.g. "democrats" and 0. Storing both the
    cloze and its index allows us to have enough data to support all possible
    editing operations.

    """

    id = "5"
    name = _("Cloze deletion")

    fact_keys_and_names = [("text", _("Text"))]
    unique_fact_keys = ["text"]
    required_fact_keys = ["text"]

    v = FactView(_("Cloze"), "5.1")
    v.q_fact_keys = ["f"]  # Generated on the fly.
    v.a_fact_keys = ["b"]  # Generated on the fly.
    fact_views = [v]

    def fact_key_format_proxies(self):
        return {"text": "text", "f": "text", "b": "text"}

    def is_fact_data_valid(self, fact_data):
        text = fact_data["text"]
        for f in self.component_manager.all("hook", "preprocess_cloze"):
            text = f.run(text)
        return bool(cloze_re.search(text))

    def _q_a_from_cloze(self, text, index):

        """Auxiliary function used by other card types to return question
        and answer for the cloze with a given index in a text which can have
        the following form:

        La [casa:house] es [grande:big]

        Use 'index=-1' to get the cloze text without brackets and without
        hints.

        """

        for f in self.component_manager.all("hook", "preprocess_cloze"):
            text = f.run(text)
        cursor = 0
        current_index = 0
        question = text
        answer = None
        while True:
            cursor = text.find("[", cursor)
            if cursor == -1:
                break
            cloze = text[cursor + 1:text.find("]", cursor)]
            if ":" in cloze:
                cloze_without_hint, hint = cloze.split(":", 1)
            else:
                cloze_without_hint, hint = cloze, "..."
            if current_index == index:
                question = question.replace(\
                    "[" + cloze + "]", "[" + hint + "]", 1)
                answer = cloze_without_hint
            else:
                question = question.replace(\
                    "[" + cloze + "]", cloze_without_hint, 1)
            cursor += 1
            current_index += 1
        for f in self.component_manager.all("hook", "postprocess_q_a_cloze"):
            question, answer = f.run(question, answer)
        return question, answer

    def fact_data(self, card):
        question, answer = self._q_a_from_cloze\
            (card.fact["text"], card.extra_data["index"])
        return {"f": question, "b": answer}

    def create_sister_cards(self, fact):
        cards = []
        text = fact["text"]
        for f in self.component_manager.all("hook", "preprocess_cloze"):
            text = f.run(text)
        for match in cloze_re.finditer(text):
            card = Card(self, fact, self.fact_views[0])
            card.extra_data["cloze"] = match.group(1)
            card.extra_data["index"] = len(cards)
            cards.append(card)
        return cards

    def _edit_clozes(self, fact, new_fact_data,
                    cloze_fact_key, cloze_fact_view):

        """Auxiliary function used by other card types to when editing clozes.
        Should take into account that not all fact views are cloze-based.

        """

        new_cards, edited_cards, deleted_cards = [], [], []
        old_clozes = cloze_re.findall(fact[cloze_fact_key])
        new_clozes = cloze_re.findall(new_fact_data[cloze_fact_key])
        # If the number of clozes is equal, just edit the existing cards.
        if len(old_clozes) == len(new_clozes):
            for card in self.database().cards_from_fact(fact):
                if "cloze" in card.extra_data:
                    index = card.extra_data["index"]
                    card.extra_data["cloze"] = new_clozes[index]
                edited_cards.append(card)
        # If not, things are a little more complicated.
        else:
            new_clozes_processed = set()
            for card in self.database().cards_from_fact(fact):
                if "cloze" in card.extra_data:
                    old_cloze = card.extra_data["cloze"]
                    index = card.extra_data["index"]
                    if old_cloze in new_clozes:
                        new_index = new_clozes.index(old_cloze)
                        card.extra_data["cloze"] = new_clozes[new_index]
                        card.extra_data["index"] = new_index
                        new_clozes_processed.add(new_clozes[new_index])
                        edited_cards.append(card)
                    else:
                        deleted_cards.append(card)
                else:
                    edited_cards.append(card)
            for new_cloze in set(new_clozes).difference(new_clozes_processed):
                new_index = new_clozes.index(new_cloze)
                card = Card(self, fact, cloze_fact_view)
                card.extra_data["cloze"] = new_cloze
                card.extra_data["index"] = new_index
                new_cards.append(card)
        return new_cards, edited_cards, deleted_cards

    def edit_fact(self, fact, new_fact_data):
        return self._edit_clozes(fact, new_fact_data,
            "text", self.fact_views[0])


class ClozePlugin(Plugin):

    name = _("Cloze deletion")
    description = _("""A card type blanking out certain fragments in a text.\n
E.g., the text \"The capital of [France] is [Paris]\", will give cards with questions \"The capital of France is [...].\" and \"The capital of [...] is Paris\".\n
Editing the text will automatically update all sister cards.\n\nYou can also specify hints, e.g. [cloze:hint] will show
 [hint] in the question as opposed to [...].""")
    components = [Cloze]


Remember to register the plugin adding to the bottom of the code above:

from mnemosyne.libmnemosyne.plugin import register_user_plugin
register_user_plugin(DecoratedVocabularyPlugin)

Regards.

cloze.py

Peter Bienstman

unread,
Jun 26, 2016, 12:15:04 AM6/26/16
to mnemosyne-...@googlegroups.com

Hi,

 

There’s no need to feel any pain, Scott’s idea to make a front-to-back card for this achieves exactly what you want without anyone needing to write any extra code.

 

https://groups.google.com/d/msg/mnemosyne-proj-users/ufnJ81XtH5E/yp3CAAlMAgAJ

 

Cheers,

 

Peter

 

From: mnemosyne-...@googlegroups.com [mailto:mnemosyne-...@googlegroups.com] On Behalf Of Ernesto Sastre


Sent: 25 June 2016 22:56
To: mnemosyne-proj-users <mnemosyne-...@googlegroups.com>

--

You received this message because you are subscribed to the Google Groups "mnemosyne-proj-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to mnemosyne-proj-u...@googlegroups.com.
To post to this group, send email to mnemosyne-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mnemosyne-proj-users/d43ce3f8-8a06-4449-b340-319c37777d80%40googlegroups.com.

Ernesto Sastre

unread,
Jun 26, 2016, 12:21:10 AM6/26/16
to mnemosyne-...@googlegroups.com

Haha it is true. It is not worth a new card type at all. Though the code is quite well structured so as to allow creating one clone of cloze deletion with minimal effort I think

You received this message because you are subscribed to a topic in the Google Groups "mnemosyne-proj-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mnemosyne-proj-users/ufnJ81XtH5E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mnemosyne-proj-u...@googlegroups.com.

To post to this group, send email to mnemosyne-...@googlegroups.com.

Chris

unread,
Jun 27, 2016, 8:15:08 AM6/27/16
to mnemosyne-proj-users
Another option would be to use the cloze deletion card type with hints (separated by a ':' from the cloze deletion), e.g.:

bla bla [cloze1 blabla cloze2:... blabla ...] bla bla bla.

The question would then look like this:

bla bla [... blabla ...] bla bla bla.

and the answer:

cloze1 blabla cloze2

Instead of the "..." you could also add hints for the words to fill in.

Another alternative is the sentence card type. It works the same as with cloze deletion card type but gives you additional options like adding pronunciation, meaning and notes. I am using this for learning a foreign language. This way I can
1. learn to translate the whole sentence
2. fill in the gaps (or replace the hints) with words in correct grammar

chris.b...@gmail.com

unread,
Jun 29, 2016, 1:11:07 AM6/29/16
to mnemosyne-proj-users
Woah.  I'm Chris also and I was just about to make this same last suggestion!  It works well, I do this all the time if I need one like you suggest.  It also works along with other parts of the card being cloze deletion separately, which the front-to-back option wouldn't.  Sometimes I'll use it for lists, or put prepositions in as a hint, too, i.e., The gnome went from [A to B through C:... to ... through ...], or something of the like.  When you get used to using the system you come up with a lot of quick and easy workarounds for just about anything you need.  Keep in mind  you can even put images in the cloze deletion brackets or hints and that allows you to do some other creative things.

    - Chris S.

chris.b...@gmail.com

unread,
Jun 29, 2016, 1:12:43 AM6/29/16
to mnemosyne-proj-users
Keep in mind you need to have a reason for having multiple cloze parts in one instance of a card.  Most often the best learning comes from keeping the information learned as granular as possible, but if you have a reason, it works well.

eliseets...@gmail.com

unread,
Sep 23, 2017, 5:09:05 PM9/23/17
to mnemosyne-proj-users
Sorry I'm not quite sure I understand. For me when I bracket something in standard cards it does nothing but adding the brackets ...
I can obvisouly do it by hand but that kind of defeats the purpose of having a package doing it for you

Peter Bienstman

unread,
Sep 24, 2017, 1:59:53 AM9/24/17
to mnemosyne-...@googlegroups.com
Hi,

That's a rather old mail you're replying to. What exactly is your problem? If you have a Cloze card with text

[a] [b] c

It will generate two cards:

Q: [...] b c
A: a

And

Q: a [...] c
A: b

Hope this helps,

Peter



From: eliseets...@gmail.com
Sent: 23 Sep 2017 23:09
To: mnemosyne-proj-users
Subject: Re: [mnemosyne-proj-users] Multiple Deletions using Cloze Deletion tool

--
You received this message because you are subscribed to the Google Groups "mnemosyne-proj-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mnemosyne-proj-u...@googlegroups.com.
To post to this group, send email to mnemosyne-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mnemosyne-proj-users/23048a7a-d224-40eb-b7ec-3ad56b320090%40googlegroups.com.

eliseets...@gmail.com

unread,
Sep 24, 2017, 9:26:00 AM9/24/17
to mnemosyne-proj-users
On Sunday, September 24, 2017 at 7:59:53 AM UTC+2, Peter Bienstman wrote:
> Hi,
>
>
>
> That's a rather old mail you're replying to. What exactly is your problem? If you have a Cloze card with text
>
>
>
> [a] [b] c
>
>
>
> It will generate two cards:
>
>
>
> Q: [...] b c
>
> A: a
>
>
>
> And
>
>
>
> Q: a [...] c
>
> A: b
>
>
>
> Hope this helps,
>
>
>
> Peter
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
Sorry I wasn't more precise. I'm interested in the same thing than the person who started the thread, which is being able to have multiple blanks without it being different cards i.e. something along the lines of
Q:
[a] d [b]

A:
a
b

Thanks.

Peter Bienstman

unread,
Sep 25, 2017, 1:20:14 AM9/25/17
to mnemosyne-...@googlegroups.com
Hi,

That's against the minimum information principle, which says that it's best that cards test only a single piece of knowledge at the same time.

However, if you realky want that, you have to indeed construct such a card manually as front to back only card.

Cheers,

Peter



From: eliseets...@gmail.com
Sent: 24 Sep 2017 15:26

Scott Youngman

unread,
Sep 25, 2017, 12:45:18 PM9/25/17
to mnemosyne-...@googlegroups.com
I am the OP. The Q card has hints or some other identifiers in brackets, while the A card has the full answers. Examples:

Q:  [1] and [2]
A:  Answer 1
     Answer 2

Q:  [Hint-1] and [Hint-2]
A:  Answer-1
     Answer-2

Although this is indeed contrary to the principle that each card should ask about one bit of information (as Peter pointed out in his reply), I find it useful when parts 1 and 2 are closely linked and I am learning them as a unit, or when each part is too easy by itself. Also when the parts occur in the same Q sentence and have the same answer, e.g. 

Q:  [Hint-xyz] blah-blah-blah, and also when [Hint-xyz] blah-blah-blah
A:  Answer-xyz

Scott

Scott Youngman

unread,
Sep 28, 2017, 1:33:02 PM9/28/17
to mnemosyne-proj-users
Another way to set up multiple blanks is to use an ellipsis, for example:
[...] and [...]
In other words, you don't need to have text or hints in the brackets.

(Correction: I am not the OP, I just replied early in the chain.)
Reply all
Reply to author
Forward
0 new messages