problems

package module
v0.0.0-...-93abc0c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 5 Imported by: 1

README

Flash Card Problem Generator

This code defines two types of problems:

  1. Fill in the blank problem
  2. Multiple choice problem

The code generates these problems from a slice of FlashCard, where each card is an instance of the type FlashCard.

Type Definitions

FlashCard

The struct FlashCard has three fields:

  • Word: A string indicating the word to be learned.
  • Sentences: a slice of strings indicating sentences containing the word.
  • Definitions: a slice of strings indicating the definitions of the given word.
FillInTheBlankProblem

The struct FillInTheBlankProblem has two fields:

  • Question: A string with some words replaced by blanks.
  • Answer: A string indicating the correct answer.
MultiChoiceProblem

The struct MultiChoiceProblem has three fields:

  • Question: A string indicating the definition of the word.
  • Choices: a slice of strings representing multiple choices for the question.
  • Answer: A string indicating the correct answer.

Functions

GenerateFillInTheBlankProblems(cards []FlashCard) []FillInTheBlankProblem

This function takes a slice of FlashCards, and returns a slice of FillInTheBlankProblems generated from the sentences in the FlashCards. It maps over each FlashCard and generates problems for each sentence in Sentences.

GenerateFillInTheBlankProblem(card FlashCard) []FillInTheBlankProblem

This function generates fill in the blank problem for a single FlashCard.

generateChoices(words []string, ans string) []string

This recursive function selects 4 random choices from the slice of words and return them as a slice. The correct answer is also included among the choices. If the correct answer is not among randomly selected words, the function recursively calls itself until it gets 4 choices including the correct answer.

GenerateMultiChoiceProblems(cards []FlashCard) []MultiChoiceProblem

This function takes a slice of FlashCards, and returns a slice of MultiChoiceProblems generated from the definitions of the FlashCards. It maps over each FlashCard and generates a MultiChoiceProblem using a random definition as the Question, four randomly selected words including the correct word as multiple choices for the question, and the correct word itself as the Answer.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FillInTheBlankProblem

type FillInTheBlankProblem struct {
	Question string
	Answer   string
}

func GenerateFillInTheBlankProblem

func GenerateFillInTheBlankProblem(card FlashCard) []FillInTheBlankProblem

func GenerateFillInTheBlankProblems

func GenerateFillInTheBlankProblems(cards []FlashCard) []FillInTheBlankProblem

type FlashCard

type FlashCard struct {
	Word        string
	Sentences   []string
	Definitions []string
}

type MultiChoiceProblem

type MultiChoiceProblem struct {
	Question string
	Choices  []string
	Answer   string
}

func GenerateMultiChoiceProblems

func GenerateMultiChoiceProblems(cards []FlashCard) []MultiChoiceProblem

Directories

Path Synopsis
internal
fp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL