Renamed gaphrase => gadialog to use gaphrase name for collocations.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Mon, 10 Feb 2020 00:54:18 +0200
changeset 1191 a3a7c8342b1c
parent 1190 f92cd37ad600
child 1192 0df788e35398
Renamed gaphrase => gadialog to use gaphrase name for collocations.
Makefile
contrib/gadialog.el
gadialog.gadialog
gadict.gaphrase
py/gadialog_srs_anki.py
--- a/Makefile	Mon Feb 10 00:41:02 2020 +0200
+++ b/Makefile	Mon Feb 10 00:54:18 2020 +0200
@@ -148,7 +148,7 @@
 INDEX_FILES := $(C5_FILES:.c5=.index)
 
 SRS_TAB_FILES := $(patsubst %.gadict,dist/srs/%.tab.txt,$(GADICT_FILES))
-SRS_ANKI_FILES := $(patsubst %.gadict,dist/anki/%.apkg,$(GADICT_FILES)) dist/anki/gaphrase.apkg
+SRS_ANKI_FILES := $(patsubst %.gadict,dist/anki/%.apkg,$(GADICT_FILES)) dist/anki/gadialog.apkg
 
 DICT_HTML_FILES := $(patsubst %.gadict,dist/html/%.html,$(GADICT_FILES))
 
@@ -680,8 +680,8 @@
 dist/anki/gadict_voa.apkg: gadict_voa.gadict py/gadict.py py/gadict_srs_anki.py $(VOA_FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name="gadict_voa" $(VOA_FREQLIST_OPT) $< $@
 
-dist/anki/gaphrase.apkg: gadict.gaphrase py/gaphrase_srs_anki.py $(MAKEFILE_LIST) | dist/anki/
-	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gaphrase_srs_anki.py -name="gaphrase" $< $@
+dist/anki/%.apkg: %.gadialog py/gaphrase_srs_anki.py $(MAKEFILE_LIST) | dist/anki/
+	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadialog_srs_anki.py -name="$*" $< $@
 
 # General rules.
 dist/anki/%.apkg: %.gadict %.del py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/gadialog.el	Mon Feb 10 00:54:18 2020 +0200
@@ -0,0 +1,86 @@
+;;; gadialog.el --- major mode for editing gadialog dialog files -*- lexical-binding: t -*-
+
+;; Copyright (C) 2019 by Oleksandr Gavenko <gavenkoa@gmail.com>
+
+;; You can do anything with this file without any warranty.
+
+;; Author: Oleksandr Gavenko <gavenkoa@gmail.com>
+;; Maintainer: Oleksandr Gavenko <gavenkoa@gmail.com>
+;; Created: 2019
+;; Version: 0.17
+;; Keywords: dict, dictionary
+
+;;; Commentary:
+;;
+;; Mode can be installed by:
+;;
+;;   (autoload 'gadialog-mode "gadialog")
+;;
+;; File association can be registered by:
+;;
+;;   (add-to-list 'auto-mode-alist (cons "\\.gadialog$" 'gadialog-mode))
+
+;;; Code:
+
+(defvar gadialog-font-lock-keywords
+  '(("^# [1-9][0-9]*" . font-lock-type-face)
+    ("^## [1-9][0-9]*" . font-lock-warning-face)
+    ("^- " . font-lock-keyword-face)))
+
+(defvar gadialog-syntax-table
+  (let ((table (make-syntax-table text-mode-syntax-table)))
+    (modify-syntax-entry ?' "w" table)
+    table))
+
+(defun gadialog-next-num ()
+  (save-excursion
+    (goto-char (point-min))
+    (let (beg end num)
+      (catch 'return
+        (when (looking-at "## \\([1-9][0-9]*\\)")
+          (setq beg (match-beginning 1)
+                end (match-end 1))
+          (setq num (string-to-number (buffer-substring beg end)))
+          (delete-region beg end)
+          (goto-char beg)
+          (setq num (1+ num))
+          (insert (int-to-string num))
+          (throw 'return num))
+        (insert "## 1\n")
+        1))))
+
+(defun gadialog-insert-template ()
+  (interactive)
+  (forward-line 0)
+  (when (looking-at "# ")
+    (forward-line 1))
+  (unless (re-search-forward "^# " (+ (point) 10240) t)
+    (goto-char (point-max)))
+  (forward-line 0)
+  (while (memq (char-before) '(?\  ?\n ?\t))
+    (delete-char -1))
+  (insert "\n# ")
+  (insert (int-to-string (gadialog-next-num)))
+  (insert "\n- \n")
+  (backward-char))
+
+(defun gadialog-insert-sentence ()
+  (interactive)
+  (forward-line 1)
+  (while (not (or (eobp)
+                  (memq (char-after) (list ?- ?#))))
+    (forward-line 1))
+  (insert ?\n)
+  (backward-char)
+  (insert "- "))
+
+
+(define-derived-mode gadialog-mode fundamental-mode "gadialog"
+  (setq font-lock-defaults '(gadialog-font-lock-keywords))
+  (define-key (current-local-map) [C-return] 'gadialog-insert-template)
+  (define-key (current-local-map) [S-return] 'gadialog-insert-sentence)
+  (set-syntax-table gadialog-syntax-table))
+
+(provide 'gadialog)
+
+;;; gadialog.el ends here
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gadialog.gadialog	Mon Feb 10 00:54:18 2020 +0200
@@ -0,0 +1,673 @@
+## 259
+# 1
+- Hello.
+- Hi.
+# 2
+- Goodbye.
+- Bye.
+# 3
+- Bye.
+- See you.
+# 4
+- Good morning.
+- Morning.
+# 5
+- Good afternoon.
+- Good afternoon.
+# 6
+- Good evening.
+- Evening.
+# 7
+- Good night.
+- Night.
+# 8
+- Hello, Ben.
+- Hi, Billy.
+# 9
+- Hi! How are you feeling?
+- Not bad. And how about you?
+# 10
+- Goodbye, dear.
+- Goodbye, darling.
+# 11
+- How are you?
+- Fine, thanks. And you?
+- I'm fine.
+# 12
+- How are you?
+- Fine, thanks.
+# 13
+- What's your surname?
+- My surname is Brown.
+# 14
+- What's your name?
+- My name is Peter.
+# 15
+- This is Pete.
+- We've met.
+# 16
+- Have you met?
+- No, we haven't.
+# 17
+- Hello. I'm Bob. I'm a reporter.
+- Good afternoon. I'm happy to meet you.
+# 18
+- Who are you?
+- I'm Yuzen Yang.
+- Please write it for me.
+# 19
+- Nice to meet you, Robert.
+- Call me Rob.
+# 20
+- What do you do?
+- I'm a welder. What do you do?
+- I'm a reporter.
+# 21
+- Excuse me, sir.
+# 22
+- Goodbye, Mr. Bishop. Thank you for your time.
+# 23
+- Tea, Grandpa?
+- Yes, please.
+# 24
+- Coffee, sir?
+- No! Thank you!
+# 25
+- Would you like tea or coffee?
+# 26
+- Thank you, Mom.
+- You're welcome.
+# 27
+- Sorry, Grandma.
+- That's OK.
+# 28
+- Let's go to the movie theater.
+- Yes, all right.
+# 29
+- Let's go to the club.
+- Sorry, I'm busy. Let's go tomorrow.
+- OK.
+# 30
+- Two apples, please.
+- Here you are.
+# 31
+- Excuse me. May I say something?
+# 32
+- Let me finish.
+# 172
+- Let me go on.
+# 33
+Dear Mr Rich.
+...
+I hope to hear from you.
+Regards.
+John Smith.
+# 34
+Hi Bob!
+...
+See you soon.
+Take care.
+John
+# 35
+- Could you speak more slowly, please?
+# 36
+- What time does it start?
+# 37
+- Where does it leave from?
+# 38
+- Sorry, could you repeat that?
+# 202
+- Can you repeat that, please?
+# 203
+- How do you say this word?
+# 204
+- How do you spell it?
+# 241
+- Could you spell that?
+# 39
+- Excuse me, ten o'clock?
+# 40
+- Can you give me some information about...
+# 41
+- What do you think?
+- It's/That's a good idea.
+# 42
+- Yes, I agree.
+# 43
+- What do you mean?
+# 44
+- I think it's important to...
+# 45
+- I don't agree.
+# 46
+- It depends.
+# 47
+- Who's he?
+- He's an old friend of mine.
+# 48
+- That's great!
+# 49
+- It's not perfect.
+# 50
+- Oh, that's a shame.
+# 51
+- I want to talk about...
+# 52
+- Let me tell you about...
+# 53
+- I like it because...
+# 54
+- Can I help you?
+- No, thanks. I'm just looking.
+# 55
+- How much is it?
+- ...
+- I need to think about it. Thanks anyway.
+# 56
+We do apologize.
+# 57
+- Don't mention it. It's OK.
+# 58
+- No problem.
+# 59
+- You don't mind?
+- Not at all.
+# 60
+- Did you have a good weekend?
+# 61
+- How was your weekend?
+- Not bad. / It was OK. / So-so.
+# 62
+- That sounds good/interesting.
+# 171
+- That sounds awful.
+# 170
+- That doesn't sound very good.
+# 63
+- Why was that?
+# 64
+- Nothing special.
+# 65
+- That's great/a shame/terrible.
+# 66
+- What did you do?
+# 67
+- Who did you go with?
+# 68
+- Why? What happened?
+# 69
+- Is two and three five?
+- That's right!
+# 70
+- Is two by three seven?
+- That's wrong / not right!
+# 71
+- That's all right!
+# 72
+- It's a pleasure!
+# 73
+- Thank you very much / so much!
+# 74
+- I do apologize.
+# 75
+- Thank you! That's very kind of you.
+# 76
+- I'd love to ...
+# 77
+- Can you do Saturday?
+- No.
+- That leaves Sunday.
+# 78
+- Tell me the time.
+- It's a quarter to nine.
+# 79
+- What time is it?
+- It's half past six.
+# 80
+- My clock is one minute fast.
+- Mine is ten minutes slow!
+# 81
+- What is the meaning of AM?
+- AM is a short form of the Latin words ante meridiem.
+# 82
+- What does she look like?
+- She is tall.
+- What is she like?
+- She is talkative.
+# 83
+- He works hard.
+- Oh no, he hardly works!
+# 84
+- Excuse me, where is Art Museum?
+- Sorry. I don't know.
+# 85
+- Where is the Museum?
+- Go straight ahead.
+# 86
+- Where are you from?
+- I am from Poland.
+# 205
+- Where do you come from?
+- I am from Italy.
+# 87
+- What city are you from?
+- I am from New York.
+# 88
+- Where do you live now?
+- I live in Baltimore now. I lived in Florida last year.
+# 89
+- Where do you live?
+- I live at 55 Georgia Street.
+# 90
+- Where do you work?
+- I work at National Radio.
+# 91
+- When do you work?
+- I work from Monday till Friday.
+# 92
+- What do they make?
+- They make plastic bags.
+# 206
+- When is your birthday?
+# 93
+- What is the address?
+- 21 California Street.
+# 94
+- Tell me where you live.
+- I live at ...
+- Give me your telephone number.
+- ...
+- Show me your driver's license.
+- Here it is.
+# 95
+- Do you live in a house?
+- No, I don't.
+- Do you live in an apartment?
+- Yes, I do.
+# 96
+- What's that?
+- It's a map.
+# 97
+- How do you travel to Los Angeles?
+- We travel by plane/car.
+- How do you travel to New York?
+- We take the train.
+# 98
+- May I help you?
+# 99
+- What does he look like?
+- He's not very tall.
+# 100
+- What color is his hair?
+- He is blond.
+# 101
+- How long does it take?
+- Sometimes it takes an hour.
+# 102
+- I am sorry I'm late.
+- No problem. That's all right.
+# 103
+- We do apologize.
+- Don't worry. It's all right.
+# 104
+- It's a nice day, isn't it?
+# 105
+- It's a wonderful day, isn't it?
+# 106
+- Do you think it will rain?
+# 107
+- Isn't it hot today?
+# 108
+- Isn't it cold today?
+- Yes, it's a little cold, but I like cold weather.
+# 109
+- Don't you like cold weather?
+# 110
+- Don't you like warm weather?
+# 111
+- Watch your step!
+# 112
+- Watch your head!
+# 113
+- What is this? What is the name of this?
+# 114
+- May I ask you a question?
+- Of course. / Sure.
+# 115
+- May I see your book?
+- I don't mind.
+# 116
+- The sooner the better.
+# 117
+- What does that mean?
+# 118
+- Can you explain what the word ferment means?
+# 119
+- Give me an example.
+# 120
+- Can you give me an example?
+# 121
+- Can you explain it to me?
+# 122
+- What does it mean?
+# 123
+- What is it?
+# 124
+- How is your mother?
+- She is all right now, but she felt terrible yesterday.
+# 125
+- How are you Tom?
+- I am OK.
+- And how is Barbara?
+- She is perfect.
+# 126
+That depends.
+# 127
+- Anything wrong?
+# 128
+- Are you in charge?
+# 129
+- Don't be embarrassed.
+# 130
+- Excuse me!
+# 183
+- Pardon me!
+# 182
+- Wait a minute!
+# 181
+- Hold on!
+# 180
+- May I add something?
+# 179
+- Just a moment!
+# 131
+- Keep calm!
+# 132
+- How do you like it?
+# 178
+- Do you really like it?
+# 177
+- What do you think of my work so far?
+# 176
+- So what do you think?
+# 175
+- What do you think of that?
+# 174
+- Do you think so?
+# 173
+- Do you like that idea?
+# 133
+- I feel bad/terrible about it/this.
+# 134
+- What's the trouble?
+# 135
+- Isn't he the greatest?
+- I've never seen anyone better.
+# 136
+- He has done such a good job.
+# 137
+- I really admire him.
+# 138
+- I think he is marvelous.
+# 139
+- I'm sorry, I'm late.
+- Don't let it happen again.
+# 140
+- I'm very/really/terribly/so sorry. I'm late.
+- Don't worry about it.
+# 141
+- Sorry to be late. I'm afraid I didn't hear my alarm clock.
+- That's OK. No problem. / I don't believe you.
+# 142
+- I'm so sorry I missed the meeting. I feel awful about it.
+- No, really. It's fine.
+# 228
+- I'm afraid I lost my keys.
+- Don't let it happen again.
+# 143
+- Hello, may I speak to Ann?
+- I'm sorry, Ann's not at home. What can I do for you?
+- Please tell her I want to speak to her.
+# 144
+- Hello, is that John?
+- No, John doesn't live here. You must have the wrong number.
+# 145
+- There's small problem here.
+# 146
+- I can't believe it.
+# 147
+- You don't understand. Let me explain you one more time.
+# 148
+- Can I speak to the person in charge, please?
+# 149
+- I hate it when kids run around and scream.
+# 150
+- Let's do something different.
+- How about going to the theater?
+- Why don't we go to a dance performance?
+- No, thanks.
+# 151
+- I don't feel like doing that.
+# 152
+- No, it's not for me.
+# 153
+- What's the weather like?
+- It's stormy.
+# 237
+- How's the weather?
+- It's cold outside.
+# 238
+- What was the weather yesterday?
+- We had a storm yesterday.
+# 154
+- The best time to visit London is July because the weather is usually OK.
+- Be prepared for small rain.
+- Bring a raincoat and a hat.
+# 155
+- I feel tired/better.
+- You shouldn't go back to work too soon.
+# 156
+- I have a terrible headache.
+- When did it start?
+- Can you recommend anything?
+- Take these tablets two times a day.
+# 157
+- Thank you for your help.
+# 158
+- Thank you for the update.
+# 159
+- I hope you're doing well.
+# 160
+- I hope you enjoyed your weekend.
+# 161
+- I hope you're having a great week / a wonderful day.
+# 162
+- It's great to hear from you.
+# 163
+- I'm reaching out about...
+# 164
+- Thank you for your help.
+# 165
+- Thank you for the update.
+# 166
+- Thanks for getting in touch.
+# 167
+- Thanks for the quick response.
+# 168
+- Can you provide me with an update on...
+# 169
+- To follow up on our meeting...
+# 184
+- You make mistakes because you are doing two things at the same time.
+# 185
+- Finally - and this is the big one - your stress level goes up.
+# 186
+- I'll let you know what happens.
+# 187
+- Let me help.
+# 188
+- Oh, don't move! I'll do it.
+- Thanks a lot.
+- No problem.
+# 189
+- Er, excuse me.
+- Yeah.
+- You dropped this.
+- Oh. Thanks so much.
+- That's OK.
+# 190
+- Shell I carry your bag?
+- No, no. It's fine, thanks.
+# 191
+- It's cold in here.
+- Shell I close the window?
+# 192
+- I don't understand. Can you explain?
+# 193
+- Cloud you give an example?
+# 194
+- Do you agree with him?
+# 195
+- What do you mean?
+# 196
+- Can you tell us more about that?
+# 197
+- I've got a question for Chris.
+# 198
+- Here are three pieces of advice I can give you.
+# 199
+- What's the matter?
+- I've got a terrible cough.
+# 200
+- What's wrong with you?
+- I have a bad sore throat.
+- I can't stay here. I'm off!
+# 201
+- Could you ring/call/phone me back?
+- Of course. Could you give me the number?
+- Just a moment. It's 123-456.
+- Let me check that. 123-456.
+- That's right.
+- Fine. Hang up and I'll call you back straightaway.
+# 207
+- Could I have one of those batteries, please?
+- Yes of course. Here you are.
+# 208
+- How much does it cost?
+# 210
+- Are you free tonight?
+- Sorry, I'm busy.
+# 211
+- What would you like to do?
+# 212
+- When would you like to go?
+# 213
+- What time's good for you?
+- How about meeting at 9 o'clock?
+- OK. See you there.
+# 214
+- Would you like to visit our parents on holidays?
+- Sounds good.
+# 215
+- The coffee here is never hot!
+# 216
+- Here you are.
+- Thanks a lot. That's kind of you.
+- You're welcome.
+# 217
+- Can I have a glass of water, please?
+- Yes, certainly.
+# 218
+- I'd like some vegetarian soup, please.
+- I'm sorry, we don't have any soup.
+# 219
+- Excuse me? Can you tell me the way to the station?
+- It's past the bank.
+# 220
+- Excuse me, how can I get to Baker Street?
+- Turn left at the crossroads.
+# 221
+- Excuse me, is there a post office near here?
+- It's on the corner of the street.
+# 222
+- Can you tell me the way to the beach?
+- Yes, you turn left at the theater. Then go straight on for about 5 minutes.
+# 223
+- Can you recommend an interesting book?
+- How about Harry Potter?
+- What's it about?
+- It's about ...
+# 224
+- I don't really like horror films.
+# 225
+- I really like sci-fi books.
+- What are they about?
+# 226
+- What kind of films do you like?
+# 242
+- What film did you see?
+# 227
+- I think you'd like it.
+# 229
+- What about having lunch now?
+- Sounds good.
+# 230
+- Could I leave a message for him?
+- Just a moment. Let me get a pen.
+# 231
+- When do you want to come back?
+# 232
+- When is the next train to London?
+# 233
+- What time does it leave?
+# 234
+- Is there a cafe in the hotel?
+# 235
+- When does the restaurant open for dinner?
+# 236
+- The gift shop is over there.
+# 239
+- What whould you like for dinner?
+- Well... Oh, I don't know.
+# 240
+- Excuse me sir. Do you have a moment?
+- Yes, OK.
+- Can I ask a couple of questions?
+# 243
+- What time did you get back?
+# 244
+- Do you think my wife would like it?
+# 245
+- Go straight on for about 300 meters.
+# 246
+- Is this seat free?
+- Sure.
+- Thanks a lot.
+# 247
+- We could take a taxi instead.
+- Or we could leave tomorrow morning.
+# 248
+- Shall we leave our bags here?
+# 249
+- You could buy a ticket online.
+# 250
+- Why not get up and go early tomorrow morning?
+# 251
+- Do I need to take this medication with food?
+# 252
+- Are there any foods, drinks, or other drugs that can change the strength or effectiveness of this medication?
+# 253
+- How long will I need to take this medication?
+# 254
+- Why is it important for me to follow a schedule while taking this medication?
+# 255
+- What should I do if I miss a dose?
+# 256
+- What are the common side effects of this medication?
+# 257
+- Can I crush my pills?
+# 258
+- What follow-up tests will I need to monitor the medication's effectiveness?
+# 259
+- What should I do if I experience an unexpected side effect to the medication?
+
--- a/gadict.gaphrase	Mon Feb 10 00:41:02 2020 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,673 +0,0 @@
-## 259
-# 1
-- Hello.
-- Hi.
-# 2
-- Goodbye.
-- Bye.
-# 3
-- Bye.
-- See you.
-# 4
-- Good morning.
-- Morning.
-# 5
-- Good afternoon.
-- Good afternoon.
-# 6
-- Good evening.
-- Evening.
-# 7
-- Good night.
-- Night.
-# 8
-- Hello, Ben.
-- Hi, Billy.
-# 9
-- Hi! How are you feeling?
-- Not bad. And how about you?
-# 10
-- Goodbye, dear.
-- Goodbye, darling.
-# 11
-- How are you?
-- Fine, thanks. And you?
-- I'm fine.
-# 12
-- How are you?
-- Fine, thanks.
-# 13
-- What's your surname?
-- My surname is Brown.
-# 14
-- What's your name?
-- My name is Peter.
-# 15
-- This is Pete.
-- We've met.
-# 16
-- Have you met?
-- No, we haven't.
-# 17
-- Hello. I'm Bob. I'm a reporter.
-- Good afternoon. I'm happy to meet you.
-# 18
-- Who are you?
-- I'm Yuzen Yang.
-- Please write it for me.
-# 19
-- Nice to meet you, Robert.
-- Call me Rob.
-# 20
-- What do you do?
-- I'm a welder. What do you do?
-- I'm a reporter.
-# 21
-- Excuse me, sir.
-# 22
-- Goodbye, Mr. Bishop. Thank you for your time.
-# 23
-- Tea, Grandpa?
-- Yes, please.
-# 24
-- Coffee, sir?
-- No! Thank you!
-# 25
-- Would you like tea or coffee?
-# 26
-- Thank you, Mom.
-- You're welcome.
-# 27
-- Sorry, Grandma.
-- That's OK.
-# 28
-- Let's go to the movie theater.
-- Yes, all right.
-# 29
-- Let's go to the club.
-- Sorry, I'm busy. Let's go tomorrow.
-- OK.
-# 30
-- Two apples, please.
-- Here you are.
-# 31
-- Excuse me. May I say something?
-# 32
-- Let me finish.
-# 172
-- Let me go on.
-# 33
-Dear Mr Rich.
-...
-I hope to hear from you.
-Regards.
-John Smith.
-# 34
-Hi Bob!
-...
-See you soon.
-Take care.
-John
-# 35
-- Could you speak more slowly, please?
-# 36
-- What time does it start?
-# 37
-- Where does it leave from?
-# 38
-- Sorry, could you repeat that?
-# 202
-- Can you repeat that, please?
-# 203
-- How do you say this word?
-# 204
-- How do you spell it?
-# 241
-- Could you spell that?
-# 39
-- Excuse me, ten o'clock?
-# 40
-- Can you give me some information about...
-# 41
-- What do you think?
-- It's/That's a good idea.
-# 42
-- Yes, I agree.
-# 43
-- What do you mean?
-# 44
-- I think it's important to...
-# 45
-- I don't agree.
-# 46
-- It depends.
-# 47
-- Who's he?
-- He's an old friend of mine.
-# 48
-- That's great!
-# 49
-- It's not perfect.
-# 50
-- Oh, that's a shame.
-# 51
-- I want to talk about...
-# 52
-- Let me tell you about...
-# 53
-- I like it because...
-# 54
-- Can I help you?
-- No, thanks. I'm just looking.
-# 55
-- How much is it?
-- ...
-- I need to think about it. Thanks anyway.
-# 56
-We do apologize.
-# 57
-- Don't mention it. It's OK.
-# 58
-- No problem.
-# 59
-- You don't mind?
-- Not at all.
-# 60
-- Did you have a good weekend?
-# 61
-- How was your weekend?
-- Not bad. / It was OK. / So-so.
-# 62
-- That sounds good/interesting.
-# 171
-- That sounds awful.
-# 170
-- That doesn't sound very good.
-# 63
-- Why was that?
-# 64
-- Nothing special.
-# 65
-- That's great/a shame/terrible.
-# 66
-- What did you do?
-# 67
-- Who did you go with?
-# 68
-- Why? What happened?
-# 69
-- Is two and three five?
-- That's right!
-# 70
-- Is two by three seven?
-- That's wrong / not right!
-# 71
-- That's all right!
-# 72
-- It's a pleasure!
-# 73
-- Thank you very much / so much!
-# 74
-- I do apologize.
-# 75
-- Thank you! That's very kind of you.
-# 76
-- I'd love to ...
-# 77
-- Can you do Saturday?
-- No.
-- That leaves Sunday.
-# 78
-- Tell me the time.
-- It's a quarter to nine.
-# 79
-- What time is it?
-- It's half past six.
-# 80
-- My clock is one minute fast.
-- Mine is ten minutes slow!
-# 81
-- What is the meaning of AM?
-- AM is a short form of the Latin words ante meridiem.
-# 82
-- What does she look like?
-- She is tall.
-- What is she like?
-- She is talkative.
-# 83
-- He works hard.
-- Oh no, he hardly works!
-# 84
-- Excuse me, where is Art Museum?
-- Sorry. I don't know.
-# 85
-- Where is the Museum?
-- Go straight ahead.
-# 86
-- Where are you from?
-- I am from Poland.
-# 205
-- Where do you come from?
-- I am from Italy.
-# 87
-- What city are you from?
-- I am from New York.
-# 88
-- Where do you live now?
-- I live in Baltimore now. I lived in Florida last year.
-# 89
-- Where do you live?
-- I live at 55 Georgia Street.
-# 90
-- Where do you work?
-- I work at National Radio.
-# 91
-- When do you work?
-- I work from Monday till Friday.
-# 92
-- What do they make?
-- They make plastic bags.
-# 206
-- When is your birthday?
-# 93
-- What is the address?
-- 21 California Street.
-# 94
-- Tell me where you live.
-- I live at ...
-- Give me your telephone number.
-- ...
-- Show me your driver's license.
-- Here it is.
-# 95
-- Do you live in a house?
-- No, I don't.
-- Do you live in an apartment?
-- Yes, I do.
-# 96
-- What's that?
-- It's a map.
-# 97
-- How do you travel to Los Angeles?
-- We travel by plane/car.
-- How do you travel to New York?
-- We take the train.
-# 98
-- May I help you?
-# 99
-- What does he look like?
-- He's not very tall.
-# 100
-- What color is his hair?
-- He is blond.
-# 101
-- How long does it take?
-- Sometimes it takes an hour.
-# 102
-- I am sorry I'm late.
-- No problem. That's all right.
-# 103
-- We do apologize.
-- Don't worry. It's all right.
-# 104
-- It's a nice day, isn't it?
-# 105
-- It's a wonderful day, isn't it?
-# 106
-- Do you think it will rain?
-# 107
-- Isn't it hot today?
-# 108
-- Isn't it cold today?
-- Yes, it's a little cold, but I like cold weather.
-# 109
-- Don't you like cold weather?
-# 110
-- Don't you like warm weather?
-# 111
-- Watch your step!
-# 112
-- Watch your head!
-# 113
-- What is this? What is the name of this?
-# 114
-- May I ask you a question?
-- Of course. / Sure.
-# 115
-- May I see your book?
-- I don't mind.
-# 116
-- The sooner the better.
-# 117
-- What does that mean?
-# 118
-- Can you explain what the word ferment means?
-# 119
-- Give me an example.
-# 120
-- Can you give me an example?
-# 121
-- Can you explain it to me?
-# 122
-- What does it mean?
-# 123
-- What is it?
-# 124
-- How is your mother?
-- She is all right now, but she felt terrible yesterday.
-# 125
-- How are you Tom?
-- I am OK.
-- And how is Barbara?
-- She is perfect.
-# 126
-That depends.
-# 127
-- Anything wrong?
-# 128
-- Are you in charge?
-# 129
-- Don't be embarrassed.
-# 130
-- Excuse me!
-# 183
-- Pardon me!
-# 182
-- Wait a minute!
-# 181
-- Hold on!
-# 180
-- May I add something?
-# 179
-- Just a moment!
-# 131
-- Keep calm!
-# 132
-- How do you like it?
-# 178
-- Do you really like it?
-# 177
-- What do you think of my work so far?
-# 176
-- So what do you think?
-# 175
-- What do you think of that?
-# 174
-- Do you think so?
-# 173
-- Do you like that idea?
-# 133
-- I feel bad/terrible about it/this.
-# 134
-- What's the trouble?
-# 135
-- Isn't he the greatest?
-- I've never seen anyone better.
-# 136
-- He has done such a good job.
-# 137
-- I really admire him.
-# 138
-- I think he is marvelous.
-# 139
-- I'm sorry, I'm late.
-- Don't let it happen again.
-# 140
-- I'm very/really/terribly/so sorry. I'm late.
-- Don't worry about it.
-# 141
-- Sorry to be late. I'm afraid I didn't hear my alarm clock.
-- That's OK. No problem. / I don't believe you.
-# 142
-- I'm so sorry I missed the meeting. I feel awful about it.
-- No, really. It's fine.
-# 228
-- I'm afraid I lost my keys.
-- Don't let it happen again.
-# 143
-- Hello, may I speak to Ann?
-- I'm sorry, Ann's not at home. What can I do for you?
-- Please tell her I want to speak to her.
-# 144
-- Hello, is that John?
-- No, John doesn't live here. You must have the wrong number.
-# 145
-- There's small problem here.
-# 146
-- I can't believe it.
-# 147
-- You don't understand. Let me explain you one more time.
-# 148
-- Can I speak to the person in charge, please?
-# 149
-- I hate it when kids run around and scream.
-# 150
-- Let's do something different.
-- How about going to the theater?
-- Why don't we go to a dance performance?
-- No, thanks.
-# 151
-- I don't feel like doing that.
-# 152
-- No, it's not for me.
-# 153
-- What's the weather like?
-- It's stormy.
-# 237
-- How's the weather?
-- It's cold outside.
-# 238
-- What was the weather yesterday?
-- We had a storm yesterday.
-# 154
-- The best time to visit London is July because the weather is usually OK.
-- Be prepared for small rain.
-- Bring a raincoat and a hat.
-# 155
-- I feel tired/better.
-- You shouldn't go back to work too soon.
-# 156
-- I have a terrible headache.
-- When did it start?
-- Can you recommend anything?
-- Take these tablets two times a day.
-# 157
-- Thank you for your help.
-# 158
-- Thank you for the update.
-# 159
-- I hope you're doing well.
-# 160
-- I hope you enjoyed your weekend.
-# 161
-- I hope you're having a great week / a wonderful day.
-# 162
-- It's great to hear from you.
-# 163
-- I'm reaching out about...
-# 164
-- Thank you for your help.
-# 165
-- Thank you for the update.
-# 166
-- Thanks for getting in touch.
-# 167
-- Thanks for the quick response.
-# 168
-- Can you provide me with an update on...
-# 169
-- To follow up on our meeting...
-# 184
-- You make mistakes because you are doing two things at the same time.
-# 185
-- Finally - and this is the big one - your stress level goes up.
-# 186
-- I'll let you know what happens.
-# 187
-- Let me help.
-# 188
-- Oh, don't move! I'll do it.
-- Thanks a lot.
-- No problem.
-# 189
-- Er, excuse me.
-- Yeah.
-- You dropped this.
-- Oh. Thanks so much.
-- That's OK.
-# 190
-- Shell I carry your bag?
-- No, no. It's fine, thanks.
-# 191
-- It's cold in here.
-- Shell I close the window?
-# 192
-- I don't understand. Can you explain?
-# 193
-- Cloud you give an example?
-# 194
-- Do you agree with him?
-# 195
-- What do you mean?
-# 196
-- Can you tell us more about that?
-# 197
-- I've got a question for Chris.
-# 198
-- Here are three pieces of advice I can give you.
-# 199
-- What's the matter?
-- I've got a terrible cough.
-# 200
-- What's wrong with you?
-- I have a bad sore throat.
-- I can't stay here. I'm off!
-# 201
-- Could you ring/call/phone me back?
-- Of course. Could you give me the number?
-- Just a moment. It's 123-456.
-- Let me check that. 123-456.
-- That's right.
-- Fine. Hang up and I'll call you back straightaway.
-# 207
-- Could I have one of those batteries, please?
-- Yes of course. Here you are.
-# 208
-- How much does it cost?
-# 210
-- Are you free tonight?
-- Sorry, I'm busy.
-# 211
-- What would you like to do?
-# 212
-- When would you like to go?
-# 213
-- What time's good for you?
-- How about meeting at 9 o'clock?
-- OK. See you there.
-# 214
-- Would you like to visit our parents on holidays?
-- Sounds good.
-# 215
-- The coffee here is never hot!
-# 216
-- Here you are.
-- Thanks a lot. That's kind of you.
-- You're welcome.
-# 217
-- Can I have a glass of water, please?
-- Yes, certainly.
-# 218
-- I'd like some vegetarian soup, please.
-- I'm sorry, we don't have any soup.
-# 219
-- Excuse me? Can you tell me the way to the station?
-- It's past the bank.
-# 220
-- Excuse me, how can I get to Baker Street?
-- Turn left at the crossroads.
-# 221
-- Excuse me, is there a post office near here?
-- It's on the corner of the street.
-# 222
-- Can you tell me the way to the beach?
-- Yes, you turn left at the theater. Then go straight on for about 5 minutes.
-# 223
-- Can you recommend an interesting book?
-- How about Harry Potter?
-- What's it about?
-- It's about ...
-# 224
-- I don't really like horror films.
-# 225
-- I really like sci-fi books.
-- What are they about?
-# 226
-- What kind of films do you like?
-# 242
-- What film did you see?
-# 227
-- I think you'd like it.
-# 229
-- What about having lunch now?
-- Sounds good.
-# 230
-- Could I leave a message for him?
-- Just a moment. Let me get a pen.
-# 231
-- When do you want to come back?
-# 232
-- When is the next train to London?
-# 233
-- What time does it leave?
-# 234
-- Is there a cafe in the hotel?
-# 235
-- When does the restaurant open for dinner?
-# 236
-- The gift shop is over there.
-# 239
-- What whould you like for dinner?
-- Well... Oh, I don't know.
-# 240
-- Excuse me sir. Do you have a moment?
-- Yes, OK.
-- Can I ask a couple of questions?
-# 243
-- What time did you get back?
-# 244
-- Do you think my wife would like it?
-# 245
-- Go straight on for about 300 meters.
-# 246
-- Is this seat free?
-- Sure.
-- Thanks a lot.
-# 247
-- We could take a taxi instead.
-- Or we could leave tomorrow morning.
-# 248
-- Shall we leave our bags here?
-# 249
-- You could buy a ticket online.
-# 250
-- Why not get up and go early tomorrow morning?
-# 251
-- Do I need to take this medication with food?
-# 252
-- Are there any foods, drinks, or other drugs that can change the strength or effectiveness of this medication?
-# 253
-- How long will I need to take this medication?
-# 254
-- Why is it important for me to follow a schedule while taking this medication?
-# 255
-- What should I do if I miss a dose?
-# 256
-- What are the common side effects of this medication?
-# 257
-- Can I crush my pills?
-# 258
-- What follow-up tests will I need to monitor the medication's effectiveness?
-# 259
-- What should I do if I experience an unexpected side effect to the medication?
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/py/gadialog_srs_anki.py	Mon Feb 10 00:54:18 2020 +0200
@@ -0,0 +1,248 @@
+# -*- coding: utf-8 -*-
+"""Anki card writer from gaphrase format"""
+
+import re
+import hashlib
+
+import os
+import io
+import sys
+import tempfile
+import shutil
+
+from gadict_util import ParseException
+
+import anki
+from anki.exporting import AnkiPackageExporter
+
+FINAME = None
+FONAME = None
+FDELNAME = None
+
+ARG_NAME_RE = re.compile("-name=(.+)")
+ARG_DELFILE_RE = re.compile("-delfile=(.+)")
+
+look_for_files = False
+for idx in range(1, len(sys.argv)):
+    arg = sys.argv[idx]
+    if arg == "--":
+        look_for_files = True
+        continue
+    if not look_for_files:
+        m = ARG_NAME_RE.match(arg)
+        if m:
+            NAME = m.group(1)
+            continue
+        m = ARG_DELFILE_RE.match(arg)
+        if m:
+            FDELNAME = m.group(1)
+            continue
+        if arg.startswith("-"):
+            raise Exception("Unsupported option format: '{:s}'".format(arg))
+    if not FINAME:
+        FINAME = arg
+        continue
+    if not FONAME:
+        FONAME = arg
+        continue
+    raise Exception("Unnecessary argument: '{:s}'".format(arg))
+
+if not FINAME:
+    raise Exception("Input file name is not passed...")
+if FONAME is None:
+    raise Exception("Output file name is not passed...")
+if not NAME:
+    NAME, _ = os.path.splitext(os.path.basename(FINAME))
+
+# if FDELNAME:
+#     FDEL = io.open(FDELNAME, mode='r', buffering=1, encoding="utf-8")
+# else:
+#     FDEL = None
+
+################################################################
+
+class Parser:
+
+    COMMENT_RE = re.compile("^; ")
+    NUM_RE = re.compile(u"^# ([1-9][0-9]*)$")
+    PHRASE_START_RE = re.compile(u"^- (.*)")
+
+    def __init__(self):
+        pass
+
+    def readline(self):
+        while True:
+            self.line = self.stream.readline()
+            self.eof = len(self.line) == 0
+            if self.eof:
+                break
+            self.lineno += 1
+            if self.COMMENT_RE.search(self.line):
+                continue
+            self.line = self.line.strip(' \n\t')
+            if len(self.line) > 0:
+                break
+
+    def parse(self, stream):
+        self.lineno = 0
+        self.stream = stream
+        self.dom = dict()
+        self.eof = False
+        try:
+            self.parse_prelude()
+            while not self.eof:
+                self.parse_article()
+        except ParseException as ex:
+            if sys.version_info.major == 2:
+                import traceback
+                traceback.print_exc()
+            raise ParseException(ex.msg, self.lineno, self.line)
+        return self.dom
+
+    def parse_prelude(self):
+        while True:
+            self.readline()
+            if self.eof:
+                return
+            m = self.NUM_RE.match(self.line)
+            if m:
+                self.num = m.group(1)
+                break
+
+    def parse_article(self):
+        """Assume we are at ``# NUM`` line."""
+        num = self.num
+        phrase_buf = []
+        phrases = []
+        while True:
+            self.readline()
+            if self.eof:
+                if len(phrase_buf) > 0:
+                    phrases.append(" ".join(phrase_buf))
+                break
+            m = self.NUM_RE.match(self.line)
+            if m:
+                if len(phrase_buf) > 0:
+                    phrases.append(" ".join(phrase_buf))
+                self.num = m.group(1)
+                break
+            m = self.PHRASE_START_RE.match(self.line)
+            if m:
+                if len(phrase_buf) > 0:
+                    phrases.append(" ".join(phrase_buf))
+                phrase_buf = [m.group(1)]
+            else:
+                phrase_buf.append(self.line)
+        if len(phrases) == 0:
+            raise ParseException("""There are no any phrases...""")
+        if num in self.dom:
+            raise ParseException("""Conflicting key: {}...""".format(num))
+        self.dom[num] = phrases
+
+FIN = io.open(FINAME, mode='r', buffering=1, encoding="utf-8")
+
+PARSER = Parser()
+try:
+    DOM = PARSER.parse(FIN)
+finally:
+    FIN.close()
+
+################################################################
+
+MODEL_CSS = """
+.card {
+  font-family: arial;
+  font-size: 20px;
+  text-align: left;
+  color: black;
+  background-color: white;
+}
+.line {
+  margin-bottom: 0.5em;
+}
+.odd {
+  color: #004000;
+}
+.even {
+  color: #000080;
+}
+"""
+
+class AnkiDbBuilder:
+
+    def __init__(self, tmpdir, name):
+        self.tmpdir = tmpdir
+        self.name = name
+
+        self.collection = collection = anki.Collection(os.path.join(self.tmpdir, 'collection.anki2'))
+
+        deck_id = collection.decks.id(self.name)
+
+        # It is essential to keep model['id'] unchanged between upgrades!!
+        model_id = int(hashlib.sha1(self.name.encode('utf-8')).hexdigest(), 16) % (2**63)
+
+        ################################################################
+        # One face card model.
+        model = collection.models.new(self.name + "_front")
+        model['did'] = deck_id
+        model['css'] = MODEL_CSS
+
+        collection.models.addField(model, collection.models.newField('Front'))
+
+        tmpl = collection.models.newTemplate('Front')
+        tmpl['qfmt'] = '<div class="front">{{Front}}</div>'
+        tmpl['afmt'] = '{{FrontSide}}'
+        collection.models.addTemplate(model, tmpl)
+
+        model['id'] = model_id
+        collection.models.update(model)
+        collection.models.save(model)
+        self.model = model
+
+    def guid(self, num):
+        h = hashlib.md5(":".join((self.name, str(num))).encode('utf-8'))
+        return h.hexdigest()
+
+    def add_note(self, num, front):
+        note = anki.notes.Note(self.collection, self.model)
+        note['Front'] = front
+        note.guid = self.guid(num)
+        self.collection.addNote(note)
+
+    def export(self, fname):
+        export = AnkiPackageExporter(self.collection)
+        export.exportInto(fname)
+
+    def close(self):
+        self.collection.close()
+
+def write_lines(buf, lines):
+    odd = True
+    for line in lines:
+        if odd:
+            buf.append("<div class='line odd'>")
+        else:
+            buf.append("<div class='line even'>")
+        buf.append("- ")
+        buf.append(line)
+        buf.append("</div>")
+        odd = not odd
+
+# Looks like anki libs change working directory to media directory of current deck
+# Therefore absolute path should be stored before creating temporary deck
+FONAME = os.path.abspath(FONAME)
+TMPDIR = tempfile.mkdtemp(dir=os.path.dirname(FONAME))
+
+try:
+    BUILDER = AnkiDbBuilder(TMPDIR, NAME)
+
+    for num, lines in DOM.items():
+        buf = []
+        write_lines(buf, lines)
+        front = "".join(buf)
+        BUILDER.add_note(num, front)
+    BUILDER.export(FONAME)
+finally:
+    BUILDER.close()
+    shutil.rmtree(TMPDIR, ignore_errors=True)
+