Giter Site home page Giter Site logo

concordance-for-vscode's Introduction

concordance-for-vscode

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:

  1. Dendron
  2. Regex highlight
  3. Command runner
  4. Run on save

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.

Setup instructions

  • install python packages
pip install pyjson5 seaborn nltk markdown beautifulsoup4 pandas
  • from the python REPL run
import nltk
nltk.download('punkt')
  • install vscode extensions
    1. Dendron
    2. Regex highlight
    3. Command runner
    4. Run on save
  • git clone this repository and move concordance.py to $dendron_directory/scripts/concordance.py.
    • the script subdirectory should be parallel to your dendron.code-workspace file.
  • 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'

Modify your workspace settings to configure command-runner and runonsave

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
        }
    ]
},

How to use

Select run command from your command pallet - this should display five options:

  1. words and phrases: highlight duplicate words and phrases
  2. reset: turn off highlighting
  3. phrases: highlight duplicate phrases only
  4. long: highlight long (greater than 10 characters) phrases only
  5. 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.

concordance-for-vscode's People

Contributors

vmasrani avatar

Watchers

James Cloos avatar  avatar

Forkers

vmasrani

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.