Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

让 pyim-update-dict-file 使用unix sort 工具来加快排序。 #32

Closed
tumashu opened this issue Mar 23, 2015 · 6 comments
Closed

让 pyim-update-dict-file 使用unix sort 工具来加快排序。 #32

tumashu opened this issue Mar 23, 2015 · 6 comments

Comments

@tumashu
Copy link
Owner

tumashu commented Mar 23, 2015

词库文件太大时, sort-regexp-fields 速度很慢,试着使用 unix sort 工具处理。

@tumashu
Copy link
Owner Author

tumashu commented Mar 23, 2015

@redguardtoo
Copy link
Collaborator

you can use (if (executable-find "sort")). keep elisp version as fallback when sort is not available.

@tumashu
Copy link
Owner Author

tumashu commented Mar 23, 2015

I have try, but failed, the problem is that I can't find the proper argument of sort

(defun test1 ()
  (interactive)
  (pyim-sort-dict-region
   (point-min)
   (point-max)))

(defun test2 ()
  (interactive)
  (sort-regexp-fields nil "^.*$" "[a-z-]+[ ]+" (point-min) (point-max)))

(defun pyim-sort-dict-region (start end)
  "将词库 buffer 中 `start' 和 `end' 范围内的词条信息按照拼音code排序"
  (if (executable-find "sort")
      (call-process-region start end
                           "sort" t t t "-g" "-k1,1")
    (sort-regexp-fields nil "^.*$" "[a-z-]+[ ]+" start end)))

same dict file ,but test1 and test2 can't get same result,

If you know the reason, please tell me.

@redguardtoo
Copy link
Collaborator

what's -g, in original answer it's -n and -s. Have you tried in shell at first?

@tumashu
Copy link
Owner Author

tumashu commented Mar 23, 2015

tested, but can't works properly ....

@tumashu
Copy link
Owner Author

tumashu commented Mar 23, 2015

我又试验了一下,这次应该可以了。。。。

@tumashu tumashu closed this as completed Mar 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants