-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge.el
44 lines (43 loc) · 1.41 KB
/
merge.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
(defun merge-dict ()
(interactive)
(setq moreLines t)
(setq filename "merge-result")
(setq towrite "")
;; (append-to-file "teststring" nil filename)
(goto-char 1)
(re-search-forward "^\\(.*?\\) \\[\\(.*?\\)\\] /(m) \\(.*?\\)/")
(setq cur-kanj (match-string 1))
(setq cur-read (match-string 2))
(setq cur-roma (match-string 3))
(forward-line 1)
(while moreLines
(re-search-forward "^\\(.*?\\) \\[\\(.*?\\)\\] /(m) \\(.*?\\)/" nil t)
(setq next-kanj (match-string 1))
(setq next-read (match-string 2))
(setq next-roma (match-string 3))
(if (string= cur-kanj next-kanj)
(if (not (string-match-p next-read cur-read))
;; same kanji different reading
(progn
(setq cur-read (concat cur-read " " next-read))
(setq cur-roma (concat cur-roma " " next-roma))
))
;; diffent kanji
(setq towrite (concat towrite cur-kanj " [" cur-read "] /(m) "
cur-roma "/\n"))
(if (> (length towrite) 10000)
(progn
(append-to-file towrite nil filename)
(setq towrite "")
))
;;nil filename) ;; write to file
(setq cur-kanj next-kanj) ;; get new entry to compare
(setq cur-read next-read)
(setq cur-roma next-roma)
)
(setq moreLines (= 0 (forward-line 1)))
)
(append-to-file towrite nil filename)
(append-to-file (concat cur-kanj " [" cur-read "] /(m) " cur-roma "/\n")
nil filename) ;; write to file
)