help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Org tag generator?


From: Jean Louis
Subject: Re: Org tag generator?
Date: Fri, 20 Dec 2024 15:14:06 +0300
User-agent: Mutt/2.2.12 (2023-09-09)

* Christopher Howard <christopher@librehacker.com> [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 <christopher@librehacker.com> [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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]