unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Christopher Howard <christopher@librehacker.com>
Cc: Help Gnu Emacs Mailing List <help-gnu-emacs@gnu.org>
Subject: Re: Org tag generator?
Date: Fri, 20 Dec 2024 15:14:06 +0300	[thread overview]
Message-ID: <Z2VfjsJSq4HBDwWS@lco2> (raw)
In-Reply-To: <87zfktueqr.fsf@librehacker.com>

* 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	other threads:[~2024-12-20 12:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18 16:39 Org tag generator? Christopher Howard
2024-12-20 12:14 ` Jean Louis [this message]
2024-12-23 17:23   ` Christopher Howard
2024-12-23 20:21     ` Jean Louis
2024-12-24 16:34       ` Christopher Howard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z2VfjsJSq4HBDwWS@lco2 \
    --to=bugs@gnu.support \
    --cc=christopher@librehacker.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).