pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/textproc/split-thai Update to 1.0



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f30dd03a4c8d
branches:  trunk
changeset: 439798:f30dd03a4c8d
user:      scole <scole%pkgsrc.org@localhost>
date:      Tue Sep 29 01:01:20 2020 +0000

description:
Update to 1.0
- small clean ups
- add thai-word-table-in-p and split-thai-word to thai-utility.el

diffstat:

 textproc/split-thai/Makefile              |   4 +-
 textproc/split-thai/files/thai-utility.el |  35 +++++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 4 deletions(-)

diffs (74 lines):

diff -r 0217aa8394e6 -r f30dd03a4c8d textproc/split-thai/Makefile
--- a/textproc/split-thai/Makefile      Tue Sep 29 00:51:20 2020 +0000
+++ b/textproc/split-thai/Makefile      Tue Sep 29 01:01:20 2020 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.10 2020/09/05 18:02:36 scole Exp $
+# $NetBSD: Makefile,v 1.11 2020/09/29 01:01:20 scole Exp $
 
-PKGNAME=       split-thai-0.9
+PKGNAME=       split-thai-1.0
 CATEGORIES=    textproc
 MAINTAINER=    pkgsrc-users%NetBSD.org@localhost
 COMMENT=       Utilities to split UTF-8 Thai text into words
diff -r 0217aa8394e6 -r f30dd03a4c8d textproc/split-thai/files/thai-utility.el
--- a/textproc/split-thai/files/thai-utility.el Tue Sep 29 00:51:20 2020 +0000
+++ b/textproc/split-thai/files/thai-utility.el Tue Sep 29 01:01:20 2020 +0000
@@ -1,3 +1,4 @@
+(require 'thingatpt)
 (require 'mule-util)
 (require 'thai-word)
 
@@ -32,14 +33,24 @@
        ;; 1 => word at this depth
        ((equal complete 1)
        (append (list thaistr)
-               (extract-thai-na (cddr nlist) thaistr) '()))
+               (extract-thai-na (cddr nlist) thaistr)))
        (t
        (error "invalid parsing for complete var"))))
      
      ;; not finished
      (t
       (append (extract-thai-na (car nlist) thaistr)
-             (extract-thai-na (cdr nlist) thaistr) '())))))
+             (extract-thai-na (cdr nlist) thaistr))))))
+
+(defun thai-word-table-in-p(thaiword)
+  "return t if thaiword is in 'thai-word-table, nil otherwise"
+  (let ((first (string-to-char (substring-no-properties thaiword 0 1)))
+       (elem)
+       (thaiwords))
+    (setq elem (assq first (cdr thai-word-table)))
+    (setq thaiwords (extract-thai-na elem ""))
+    (if (and elem thaiwords (member thaiword thaiwords))
+       t nil)))
 
 (defun thai-word-table-save(filename &optional alist)
   "save thai words extracted from a nested-alist table to
@@ -164,6 +175,26 @@
       (write-region nil nil lispfile))
     line_count))
 
+(defun split-thai-word()
+  "Break Thai word at point by inserting spaces at word
+boundaries. (wrapper for 'thai-break-words)"
+  (interactive)
+  (let* ((start (point))
+        (bounds (bounds-of-thing-at-point 'word))
+        (p1 (car bounds))
+        (p2 (cdr bounds))
+        (instr (buffer-substring-no-properties p1 p2))
+        (outstr))
+    (with-temp-buffer
+      (insert instr)
+      (goto-char(point-min))
+      (thai-break-words " ")
+      (split-thai-numbers (point-min) (point-max))
+      (setq outstr (buffer-string)))
+    (delete-region p1 p2)
+    (insert outstr)
+    (goto-char start)))
+
 (defun split-thai-line()
   "Break Thai words from point to end of line by inserting a
 space at word boundaries. (wrapper for 'thai-break-words)"



Home | Main Index | Thread Index | Old Index