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 <mopto...@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: signature.asc
Description: Message signed with OpenPGP

Reply via email to