This is a little writing tool I made while procrastinating starting my thesis, based on Concordance from David Deutsch. It is a python script which highlights duplicate words and phrases in order to find and eliminate repetitions.
I've cobbled it together using python and four extensions:
In a perfect world I would have written this in javascript and it would be a simple vscode extension (accepting pull requests!). I don't know how to do that however, and so instead I've used python to write custom regex, which are then fed to regex highlight. Run on save is used to update the highlights upon save, and command runner saves an .args token which changes the settings. Dendron provides the environment where the markdown notes live.
- install python packages
pip install pyjson5 seaborn nltk markdown beautifulsoup4 pandas
- from the python REPL run
import nltk
nltk.download('punkt')- install vscode extensions
- git clone this repository and move concordance.py to
$dendron_directory/scripts/concordance.py.- the
scriptsubdirectory should be parallel to yourdendron.code-workspacefile.
- the
- change line 11 - 13 of concordance.py to the appropriate paths:
SETTINGS_PATH = '/Users/vmasrani/dev/phd/dendron/dendron.code-workspace'
ARGS_PATH = '/Users/vmasrani/dev/phd/dendron/scripts/.args'
OUT_PATH = '/Users/vmasrani/dev/phd/dendron/vault/assets/concordance.csv'Add the following entries to your workspace settings json (command pallet > Preferences: Open Workspace Settings (JSON)), with the paths in emeraldwalk.runonsave.commands.cmd appropriately changed to point to your python interpreter and concordance.py file:
"command-runner.commands": {
"reset": "echo '0 0 0 1' >! ${config:dendron.rootDir}/scripts/.args && ${config:python.pythonPath} ${config:dendron.rootDir}/scripts/concordance.py '${file}'",
"words": "echo '1 5 1 0' >! ${config:dendron.rootDir}/scripts/.args && ${config:python.pythonPath} ${config:dendron.rootDir}/scripts/concordance.py '${file}'",
"phrases": "echo '2 6 0 0' >! ${config:dendron.rootDir}/scripts/.args && ${config:python.pythonPath} ${config:dendron.rootDir}/scripts/concordance.py '${file}'",
"words_and_phrases": "echo '1 6 0 0' >! ${config:dendron.rootDir}/scripts/.args && ${config:python.pythonPath} ${config:dendron.rootDir}/scripts/concordance.py '${file}'",
"long": "echo '4 10 0 0' >! ${config:dendron.rootDir}/scripts/.args && ${config:python.pythonPath} ${config:dendron.rootDir}/scripts/concordance.py '${file}'"
},
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.md$",
"isAsync": true,
"cmd": "/Users/vmasrani/miniconda3/envs/ml3/bin/python /Users/vmasrani/dev/phd/dendron/scripts/concordance.py ${file}",
"autoClearConsole": true
}
]
},Select run command from your command pallet - this should display five options:
- words and phrases: highlight duplicate words and phrases
- reset: turn off highlighting
- phrases: highlight duplicate phrases only
- long: highlight long (greater than 10 characters) phrases only
- words: highlight duplicate words only
Select one of the options, then the script should automatically run every time you save a markdown file. Looking at the Run on Save output panel should reveal a printout of each duplicate.
