emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Damon Permezel <permezel@me.com>
To: Matt Price <moptop99@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: table --> org-drill
Date: Wed, 24 Apr 2019 23:54:01 +1000	[thread overview]
Message-ID: <EDC20092-C745-4E08-A6B2-7DC79F1E0F1C@me.com> (raw)
In-Reply-To: <CAN_Dec-H2BYQ_4uBJZ59P1GFZT6ZZsCDiCi2Dj7=y=pGiWhzWw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 3500 bytes --]

Hi.
I am trying to learn Japanese and I am creating word lists as:

Kanji/Katakana <TAB> Katakana <TAB> meaning

理由	りゆう	reason
地理	ちり	geography
無理な	むりな	impossible
特に	とくに	especially
安い	やすい	cheap

I just now scraped together the following to turn it into org-drill format.
I have not written any elisp for probably at least 40 years so, as they say, よろしくお願いします。
You should be able to munge it for your purposes.

(defun txt-to-TSV ()
  "turn a tab-separated text line into TSV"
  (interactive)
  (save-mark-and-excursion
    (save-restriction
      (let ((beg (progn (beginning-of-line) (point)))
	    (end (progn (forward-line)
			(if (looking-at "\n")
			    (- (point) 1)
			  (point))))
	    (tabs nil)
	    (tsv (vector))
	    (prev nil))

	(narrow-to-region beg end)
	(goto-char beg)
	(setq tabs (vector beg))
	(setq prev beg)
	(while (< (point) end)
	  (if (looking-at "\t")
	      (progn
		(setq tabs (vconcat tabs (vector (point))))
		(setq tsv  (vconcat tsv (vector (buffer-substring prev (point)))))
		(setq prev (+ 1 (point)))))
	  (forward-word))
	(setq tabs (vconcat tabs (vector end)))
	(setq tsv  (vconcat tsv (vector (buffer-substring prev (point)))))
	))
    ))

(defun txt-to-drill (arg)
  "convert TSV to drill"
  (interactive "p")

  (while (> arg 0)
    (setq arg (- arg 1))
    (let ((tsv (txt-to-TSV))
	  (query (concat
		  "*** Query	:drill:\n"
		  "    :PROPERTIES:\n"
		  "    :END:\n"))
	  (answer (concat
		   "**** Answer\n")))
      (if (> (length tsv) 2)
	  (progn
	    (beginning-of-line)
	    (insert "\n" query (aref tsv 0))
	    (insert "\n" answer (aref tsv 1))
	    (let ((i 2))
	      (while (< i (length tsv))
		(insert "\n" (aref tsv i))
		(setq i (+ 1 i))))
	    (insert "\n")
	    (insert "# ")
	    (beginning-of-line)
	    (forward-line)))
      )))



> On 2019-Apr-22, at 23:18, Matt Price <moptop99@gmail.com> wrote:
> 
> Hello everyone,
> 
> I'm taking an informal but intensive Nepali language class. There's no textbook, and vocabulary comes rapidly from the teacher during lcass.  I end up with notes that look like this:
> 
> **** yo & tyo-based constructions
> 
> *yo*
> | yatti  | this much  |
> | katti  | how much   |
> | yaha   | this place |
> | kaahaa | where      |
> | yasto  |            |
> | kasto  | how        |
> | yasari |            |
> | kasari |            |
> 
> *tyo* and *u*
> 
> similar, but over there.  nearly synonymous is "u", which in principle is reserved for persons, but is used for both. "u" can also be in between yo and two, between this and that.
> 
> - u kosto manche ho? ::  what kind of person is he?
> - u kosto manche ho? :: u asal manche ho
> 
> ---------
> So there are two types of notes here --
> - vocabulary in a 2-column table (sometimes there is a third or fourth table, with devenagri and a note of some kind, ubt thosse have been rare)
> - example sentences in definition lists -- sometimes they are nepali --> english, and osmetimes question --> answer
> 
> I would like ot convert both these types of construction to flashcards using org-drill, but doing so by hand would be prohibitively time-consuming.  Has anyone already written some code to doe these kinds of ocnversions? My head is so scrambled fro mthis ocurse that it's hard for me to think in lisp...
> 
> THank you!
> 
> Matt
> I would like to convert


[-- Attachment #1.2: Type: text/html, Size: 14937 bytes --]

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-04-24 13:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-22 13:18 table --> org-drill Matt Price
2019-04-24 13:54 ` Damon Permezel [this message]
2019-04-24 13:57   ` Damon Permezel
2019-04-25  8:14     ` Damon Permezel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EDC20092-C745-4E08-A6B2-7DC79F1E0F1C@me.com \
    --to=permezel@me.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=moptop99@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).