From mboxrd@z Thu Jan 1 00:00:00 1970 From: Damon Permezel Subject: Re: table --> org-drill Date: Wed, 24 Apr 2019 23:57:11 +1000 Message-ID: <50108959-2F57-417B-8962-D6E02E2C84EA@me.com> References: Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Content-Type: multipart/signed; boundary="Apple-Mail=_7D5C88CD-CC43-4D76-AE35-3ABC80C06079"; protocol="application/pgp-signature"; micalg=pgp-sha256 Return-path: Received: from eggs.gnu.org ([209.51.188.92]:35343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJIOm-0002xs-4p for emacs-orgmode@gnu.org; Wed, 24 Apr 2019 09:57:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJIOj-0001q1-NV for emacs-orgmode@gnu.org; Wed, 24 Apr 2019 09:57:20 -0400 Received: from mr85p00im-ztdg06011901.me.com ([17.58.23.198]:17796) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hJIOj-0001op-AZ for emacs-orgmode@gnu.org; Wed, 24 Apr 2019 09:57:17 -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=_7D5C88CD-CC43-4D76-AE35-3ABC80C06079 Content-Type: multipart/alternative; boundary="Apple-Mail=_7C151385-02E5-4612-8D39-D914B2CD1E61" --Apple-Mail=_7C151385-02E5-4612-8D39-D914B2CD1E61 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Just noticed a bug as I was reading my post. Just if argument-prefix is = applied, it will keep trying a line with no tabs (or less than 2) and = not advance the line. I=E2=80=99m sure there are more=E2=80=A6. > On 2019-Apr-24, at 23:54, Damon Permezel wrote: >=20 > Hi. > I am trying to learn Japanese and I am creating word lists as: >=20 > Kanji/Katakana Katakana meaning >=20 > =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 >=20 > 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. >=20 > (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)) >=20 > (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))))) > )) > )) >=20 > (defun txt-to-drill (arg) > "convert TSV to drill" > (interactive "p") >=20 > (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))) > ))) >=20 >=20 >=20 >> 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 >=20 --Apple-Mail=_7C151385-02E5-4612-8D39-D914B2CD1E61 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Just = noticed a bug as I was reading my post.  Just if argument-prefix is = applied, it will keep trying a line with no tabs (or less than 2) and = not advance the line.  I=E2=80=99m sure there are more=E2=80=A6.

On 2019-Apr-24, at 23:54, Damon Permezel <permezel@me.com> = wrote:

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=_7C151385-02E5-4612-8D39-D914B2CD1E61-- --Apple-Mail=_7D5C88CD-CC43-4D76-AE35-3ABC80C06079 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/xxnsnwZRAPzw7sFAlzAazcACgkQsnwZRAPz w7u8ghAAoCbd/AQ+J8m3MuAALYsMM7nyTHazR7qQVzQuJyQWMkSaXMRR+89UzrWg LQMRB7NJdLV2nVNUJ9eFeUGQk2QWJ6q47LljjDs4KgIGPMppgUEgQRXG+v+ynYgm fvd9sOzYp6N25gIynemBPIL42v/7aBTVu9vjLSNSToyCEKs/opNhqTzU7i837iMH S6Eq7kkYQlmNzLW5eo46xu6sqOfKmX3y/Gp/85KhIgMMzXe5EgT+HA9YdLmrevsq 8YGlywp9e/V3XSnHv3B3wV+QBarRRCeQkgdRXN+zTovUuO2uW4MS3hFHI0jlNr9d VWxyF9LacytQTbq9orZYn6g/qFqruZ+KQAdviV1ZUl90rDr5aa0Y1EbbHEv6O+bq MCtVdpUyoaWvlcjoZMbMQnaA875xEW1iMKxHEdM2pLPzPJXxoYgPEmzv6WLuk3g8 Mw0IxPU90GL2BUQbEVMLOxg20AOFeEaZYz1kyqz5cWB8jLVoPE7fiiGkUzGO4Es/ DoZAb58bBh5qzJHfCv9Q3xi0PaFisVJhcbxOgNYuP9/hRiAttsTfKgQWQm+eOrj7 ueVF5SjKyQubrhuvgqU+zBc/xIEzrAaP9Z8QMchtk8dXLPdkRMZBGPwovIkXfbo0 1JBX2wyF4sH0JTDaU5zWJSDXTxck/cKP2XudZb8H32c96XmNNwE= =uk6V -----END PGP SIGNATURE----- --Apple-Mail=_7D5C88CD-CC43-4D76-AE35-3ABC80C06079--