From mboxrd@z Thu Jan 1 00:00:00 1970 From: Damon Permezel Subject: Re: table --> org-drill Date: Wed, 24 Apr 2019 23:54:01 +1000 Message-ID: References: Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Content-Type: multipart/signed; boundary="Apple-Mail=_072962A3-127E-4654-9B12-7160F27C921C"; protocol="application/pgp-signature"; micalg=pgp-sha256 Return-path: Received: from eggs.gnu.org ([209.51.188.92]:33917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJILj-0008Qs-Uj for emacs-orgmode@gnu.org; Wed, 24 Apr 2019 09:54:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJILi-0007if-8W for emacs-orgmode@gnu.org; Wed, 24 Apr 2019 09:54:11 -0400 Received: from mr85p00im-ztdg06011201.me.com ([17.58.23.181]:61216) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hJILh-0007hX-AW for emacs-orgmode@gnu.org; Wed, 24 Apr 2019 09:54:10 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Matt Price Cc: Org Mode --Apple-Mail=_072962A3-127E-4654-9B12-7160F27C921C Content-Type: multipart/alternative; boundary="Apple-Mail=_2E448972-0984-4AF9-ACA9-1D058BC8705F" --Apple-Mail=_2E448972-0984-4AF9-ACA9-1D058BC8705F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi. I am trying to learn Japanese and I am creating word lists as: Kanji/Katakana Katakana meaning =E7=90=86=E7=94=B1 =E3=82=8A=E3=82=86=E3=81=86 reason =E5=9C=B0=E7=90=86 =E3=81=A1=E3=82=8A geography =E7=84=A1=E7=90=86=E3=81=AA =E3=82=80=E3=82=8A=E3=81=AA = impossible =E7=89=B9=E3=81=AB =E3=81=A8=E3=81=8F=E3=81=AB especially =E5=AE=89=E3=81=84 =E3=82=84=E3=81=99=E3=81=84 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, =E3=82=88=E3=82=8D=E3=81=97=E3=81=8F=E3=81=8A=E9=A1=98=E3=81=84=E3=81= =97=E3=81=BE=E3=81=99=E3=80=82 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 wrote: >=20 > Hello everyone, >=20 > 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: >=20 > **** yo & tyo-based constructions >=20 > *yo* > | yatti | this much | > | katti | how much | > | yaha | this place | > | kaahaa | where | > | yasto | | > | kasto | how | > | yasari | | > | kasari | | >=20 > *tyo* and *u* >=20 > 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. >=20 > - u kosto manche ho? :: what kind of person is he? > - u kosto manche ho? :: u asal manche ho >=20 > --------- > 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 >=20 > 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... >=20 > THank you! >=20 > Matt > I would like to convert --Apple-Mail=_2E448972-0984-4AF9-ACA9-1D058BC8705F Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hi.
I am trying to learn Japanese and I am = creating word lists as:

Kanji/Katakana <TAB> Katakana <TAB> = meaning

=E7=90=86=E7=94=B1 =E3=82=8A=E3=82=86=E3=81=86 = reason
=E5=9C=B0=E7=90=86 = =E3=81=A1=E3=82=8A geography
=E7=84=A1=E7=90=86=E3=81=AA =E3=82=80=E3=82=8A=E3=81=AA = impossible
=E7=89=B9=E3=81=AB = =E3=81=A8=E3=81=8F=E3=81=AB especially
=E5=AE=89=E3=81=84 =E3=82=84=E3=81=99=E3=81=84 = 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, = =E3=82=88=E3=82=8D=E3=81=97=E3=81=8F=E3=81=8A=E9=A1=98=E3=81=84=E3=81=97=E3= =81=BE=E3=81=99=E3=80=82
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

= --Apple-Mail=_2E448972-0984-4AF9-ACA9-1D058BC8705F-- --Apple-Mail=_072962A3-127E-4654-9B12-7160F27C921C Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEXHL/yfpKJqfg/xxnsnwZRAPzw7sFAlzAankACgkQsnwZRAPz w7vUOg//eDFfJHyOXb0+dFXh8zMmBLwPonOfNvU84ADMEL5RyD5+HdGwYI0xhAhC lVIhA5qsbz4OcveiAW98gMWjujXzUiyFGVpX9g8XcHbUy3+/aXLC45PUPRwdKQ+7 HJ6ZZQA1RV2wKJV0W1RoViBY4B4iXqUrixjUtMdjLfA20WS/l2mc9yxyegiOOCgc tOcKis+xq9rhguGim8jBnuAfqQDhnLUWlGFEmV6iLLo9hsvugd5N8aWy3nAj9weg BITbmtOPQxeSR/xPWNdMKP1ttmEwZcYuuwYYMOjTdpXBRRNCIBxTSFsAK081xrU7 qvmUl5IEKSJaw1/CRGVy8AkEg77g1U9MEpY6ZOznmXKzMbIrxrUBVaaC6WCG0z2O j7qDpahv+rfeqTDceB1QyNZQw/7EHqUL3/+auvHVgqGGS1zOsrpSK9YNZlH+l4e8 nZHUYMKuNamp00ePJgFt8voFH4zULBlTCuj/4A5zoBHXUBfH1sKzG9WotkAMRSlX 7cKC41Fu0agYng+z73dLqUzeslGJJN0aP1lvmayenHxRUzOOD341r3w6tgsgFWHN qlt4LQ82YoGWyBEEdX+BCcmy1n2DSMfsqGfrwUPI0OuGyp4l7UMHuTwcnv0m9kNW 5rJuPot+75+FDeAVW1RRYftpsBafGBc06rykdFsl0/e12D2DUI0= =BblI -----END PGP SIGNATURE----- --Apple-Mail=_072962A3-127E-4654-9B12-7160F27C921C--