From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Org tag generator? Date: Fri, 20 Dec 2024 15:14:06 +0300 Message-ID: References: <87zfktueqr.fsf@librehacker.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20095"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.12 (2023-09-09) Cc: Help Gnu Emacs Mailing List To: Christopher Howard Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 20 13:17:19 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tObwV-00053w-5C for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 20 Dec 2024 13:17:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tObvw-0001MN-Ud; Fri, 20 Dec 2024 07:16:44 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tObvv-0001Lr-Jh for help-gnu-emacs@gnu.org; Fri, 20 Dec 2024 07:16:43 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tObvt-0004lU-NU for help-gnu-emacs@gnu.org; Fri, 20 Dec 2024 07:16:43 -0500 Original-Received: from localhost ([::ffff:41.75.172.173]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001BF31.0000000067656027.000FB7E2; Fri, 20 Dec 2024 05:16:39 -0700 Mail-Followup-To: Christopher Howard , Help Gnu Emacs Mailing List Content-Disposition: inline In-Reply-To: <87zfktueqr.fsf@librehacker.com> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148894 Archived-At: * Christopher Howard [2024-12-18 19:42]: > Hi, I use org-set-tags-command a lot in an org document where I > store links and notes to various subjects of interest to me. I was > wondering if I could have Emacs auto-generate tag suggestions based > on the content in the node being tagged. Like, if the node has words > like "senator" or "lawmakers" it suggests ":politics:". The > suggestions being trained from the other nodes and tags in the > document. Well... sure it can work, somehow, as you know Emacs and Lisp can do basically anything. (defun generate-keywords-1 (s) (let* ((case-fold-search t) (s (replace-regexp-in-string "[^[:word:]]" " " s)) (s (replace-regexp-in-string " +" " " s)) (s (replace-regexp-in-string "^[[:space:]]+" "" s)) (s (replace-regexp-in-string "[[:space:]]+$" "" s)) (s (split-string s)) (s (seq-uniq s)) (s (mapcar 'too-short s)) (s (delete nil s)) (s (string-join s ", "))) s)) (defun generate-keywords (string &optional from to) (interactive (if (use-region-p) (list nil (region-beginning) (region-end)) (let ((bds (bounds-of-thing-at-point 'paragraph))) (list nil (car bds) (cdr bds))))) (let (workOnStringP inputStr outputStr) (setq workOnStringP (if string t nil)) (setq inputStr (if workOnStringP string (buffer-substring-no-properties from to))) (setq outputStr (generate-keywords-1 inputStr)) (if workOnStringP outputStr (save-excursion (delete-region from to) (goto-char from) (insert outputStr))))) So now I use this function as: (generate-keywords "This sounds kind of like what an LLM does but the requirements are much lighter, since it just needs to know how I have tagged all my other nodes, which is only a few thousand nodes.") ➜ "This, sounds, kind, like, what, does, requirements, much, lighter, since, just, needs, know, have, tagged, other, nodes, which, only, thousand" Though that is not so specific. It would be better using Local LLM, then you make it generate keywords: (rcd-llm (concat "Generate only 3 major keywords for: " "Is there a project out there like this already for Emacs? Or a suggestion on a not too complicated way to tie the tagging functionality to some external software that does this sort of thing?")) 1. Emacs 2. Tagging 3. Integration > Is there a project out there like this already for Emacs? Or a suggestion on a not too complicated way to tie the tagging functionality to some external software that does this sort of thing? Here are 3 major keywords for the given text: 1. Emacs 2. Tagging 3. Integration > -- > 📛 Christopher Howard > 🚀 gemini://gem.librehacker.com > 🌐 http://gem.librehacker.com > > בראשית ברא אלהים את השמים ואת הארץ Based on the provided text, the 3 major keywords are: 1. **Gemini** 2. **Librehacker** 3. **Hebrew** (or **Bible**, as the text appears to be a quote from the Book of Genesis) * Christopher Howard [2024-12-18 19:42]: > Hi, I use org-set-tags-command a lot in an org document where I > store links and notes to various subjects of interest to me. I was > wondering if I could have Emacs auto-generate tag suggestions based > on the content in the node being tagged. Like, if the node has words > like "senator" or "lawmakers" it suggests ":politics:". The > suggestions being trained from the other nodes and tags in the > document. Here are 3 major keywords for the given text: 1. **Org-Mode** 2. **Tag Suggestions** 3. **Emacs Automation** -- Jean Louis