Re: [O] table --> org-drill

2019-04-25 Thread Damon Permezel


> On 2019-Apr-24, at 23:57, Damon Permezel  wrote:
> 
> 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’m sure there are more….
> 

This version is somewhat better.  It skips comment lines and org headers lines, 
plus fixes a few bugs, while introducing an equal measure of new ones + 1.

(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 (end-of-line) (point)))
(tsv (vector))
(prev nil))

(narrow-to-region beg end)
(goto-char beg)
(when (and (not (= (following-char) ?#))
   (not (= (following-char) ?*)))
  (setq prev beg)
  (while (< (point) end)
(when (looking-at "\t")
  (setq tsv  (vconcat tsv (vector (buffer-substring prev (point)
  (setq prev (+ 1 (point
(forward-word))

  (setq tsv (vconcat tsv (vector (buffer-substring prev (point))
tsv


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

  (let ((query (concat
"*** Query  :drill:\n"
":PROPERTIES:\n"
":END:\n"))
(answer (concat
 " Answer\n")))
(while (> arg 0)
  (setq arg (- arg 1))
  (let ((tsv (txt-to-TSV)))
(if (> (length tsv) 1)
(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



signature.asc
Description: Message signed with OpenPGP


Re: [O] table --> org-drill

2019-04-24 Thread Damon Permezel
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’m sure there are more….

> On 2019-Apr-24, at 23:54, Damon Permezel  wrote:
> 
> Hi.
> I am trying to learn Japanese and I am creating word lists as:
> 
> Kanji/Katakana  Katakana  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 > > 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
> 



signature.asc
Description: Message signed with OpenPGP


Re: [O] table --> org-drill

2019-04-24 Thread Damon Permezel
Hi.
I am trying to learn Japanese and I am creating word lists as:

Kanji/Katakana  Katakana  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  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



signature.asc
Description: Message signed with OpenPGP


[O] table --> org-drill

2019-04-22 Thread Matt Price
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