Skip to content

A package to help org-mode users discover similar or related notes in a directory.

Notifications You must be signed in to change notification settings

ursulogalvan/org-similarity

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

org-similarity

org-similarity is a package to help Emacs org-mode users discover similar or related files. Under the hood, it uses Python and scikit-learn for text feature extraction, and nltk for text pre-processing. More specifically, this package provides a function to recursively scan a given directory for org files, clean their content by stripping the front matter and some undesired characters, tokenize them, replace each token with its respective linguistic stem, generate a TF-IDF sparse matrix, and calculate the cosine similarity between these documents and the buffer you are currently working on.

./example.gif

Dependencies

To ensure you have the latest packages, run:

$ pip install -U scikit-learn nltk

Installation

Via straight.el

(straight-use-package
 '(org-similarity :type git :host github :repo "brunoarine/org-similarity"))

Doom Emacs

(package! org-similarity
  :recipe (:host github :repo "brunoarine/org-similarity"))

Via cloning

You can also clone the repository somewhere in your load-path. If you would like to assist with development, this is the way to go.

To do that:

  1. Create a directory where you’d like to clone the repository, e.g. mkdir ~/projects.
  2. cd ~/projects
  3. git clone https://github.com/brunoarine/org-similarity.git

You now have the repository cloned in ~/projects/org-similarity/. Now paste the following sexps in your init-file (e.g. ~/.emacs.d/init.el):

;; If you cloned the repository
(add-to-list 'load-path "~/projects/org-similarity/") ;Modify with your own path
(require 'org-similarity)

You can also copy org-similarity/ somewhere where load-path can access it, but you’d have to update the file manually.

Configuration

There are a few variables that can be set to customize how org-similarity operates and generates the list of similar documents:

;; directory to scan for possibly similar documents.
;; org-roam users might want to change it to org-roam-directory
(setq org-similarity-directory org-directory)
;; the language passed to nltk's Snowball stemmer
(setq org-similarity-language "english")
;; how many similar entries to list at the end of the buffer
(setq org-similarity-number-of-documents 10)
;; whether to prepend the list entries with their cosine similarity score
(setq org-similarity-show-scores nil)

Usage

Use M-x org-similarity-insert-list RET to insert a list of org-mode links to similar files at the end of your current buffer.

License

Copyright 2020 Bruno Arine

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About

A package to help org-mode users discover similar or related notes in a directory.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 64.2%
  • Emacs Lisp 35.8%