1

Is there a semantic script/db for emacs which I could use to extend some search functions?

E.g. Search for create with helm-org and get both headings from the example below returned:

* Create foo
* Make foo
Drew
  • 75,699
  • 9
  • 109
  • 225
jjk
  • 705
  • 4
  • 16
  • 3
    The question is too vague. The only helpful part of it is the example, and even then readers have to guess that what you're asking is for some Emacs function that can test words to see if they are synonyms. Please clarify the question. – Drew Mar 26 '22 at 14:35
  • 1
    This is a great question! As a new Doom user, when I type `M-x copy line` some relevant commands don't show up, such as `evil-yank-line`. How do we get Emacs to not only search for a word, but search for synonyms of a word? – Zaz Jun 02 '23 at 06:52

2 Answers2

2

If you want to test words to see if they are synonyms then one possibility is to use a thesaurus inside Emacs. (Another is to check a thesaurus outside Emacs.)

Library synonyms.el (code) gives you access to a word base from Roget's thesaurus inside Emacs. You can combine that with "search" or whatever, and look up any pair of words, to see if they're present as synonyms in the thesaurus.


Library synonyms.el is mainly for exploring the thesaurus interactively. But I've just added function synonyms-p, which just tests whether a given word is a synonym of another:

(synonyms-p "create" "make")    ; Returns non-nil.
(synonyms-p "create" "chicken") ; Returns nil.
Drew
  • 75,699
  • 9
  • 109
  • 225
0

This may be overkill for your use case, but there is a recent blog post titled Semantic Search for Org roam that uses OpenAI's text-embedding-ada-002 to compare blocks of text. It works by using machine-learning techniques to transform a given block of text into a point in 1536-dimensional space. Then, given an input, you can search for similar text simply by looking for nearby points in that space.

Luis Moneda's work allows you to search your Org roam files in a very advanced semantic way by:

  1. Signing up for an OpenAI account and getting an API key
  2. Running Luis's Semantic Search for Org Roam Python server
  3. Adding a command to Emacs to use this server

Note that I have not audited this code. And it may cost (Luis stated it cost him $0.14).

Zaz
  • 123
  • 6