Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat: added nouns and scripts to make it easier

Elijah Potter8f108ecf32c8
diff --git a/harper-cli/src/main.rs b/harper-cli/src/main.rs
index 2ff8044b9..21b58024f 100644
--- a/harper-cli/src/main.rs
+++ b/harper-cli/src/main.rs
@@ -1,5 +1,6 @@
#![doc = include_str!("../README.md")]
+use std::iter::once;
use std::path::{Path, PathBuf};
use anyhow::format_err;
@@ -8,7 +9,7 @@ use clap::Parser;
use harper_comments::CommentParser;
use harper_core::linting::{LintGroup, LintGroupConfig, Linter};
use harper_core::parsers::Markdown;
-use harper_core::{remove_overlaps, Document, FullDictionary};
+use harper_core::{remove_overlaps, Dictionary, Document, FullDictionary};
#[derive(Debug, Parser)]
enum Args {
@@ -25,7 +26,9 @@ enum Args {
Parse {
/// The file you wish to parse.
file: PathBuf
- }
+ },
+ /// Emit decompressed, line-separated list of words in Harper's dictionary.
+ Words
}
fn main() -> anyhow::Result<()> {
@@ -79,6 +82,20 @@ fn main() -> anyhow::Result<()> {
println!("{:?}", token);
}
+ Ok(())
+ }
+ Args::Words => {
+ let dict = FullDictionary::curated();
+
+ let mut word_str = String::new();
+
+ for word in dict.words_iter() {
+ word_str.clear();
+ word_str.extend(word);
+
+ println!("{}", word_str);
+ }
+
Ok(())
}
}
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dict
index ee0fb8936..5015a0fa3 100644
--- a/harper-core/dictionary.dict
+++ b/harper-core/dictionary.dict
@@ -2509,6 +2509,7 @@ DPT/1
DST/1
DTP/1
DUI/1
+UI/SM
DVD/1S
DVR/14SM
DWI/14
@@ -8967,6 +8968,7 @@ Shakespearean/51M
Shana/2M
Shandong/2M
Shane/2M
+Shang/SM
Shanghai/21M
Shankara/M
Shanna/2M
@@ -17266,6 +17268,7 @@ cognate/51MS
cognition/1AM
cognitional/5
cognitive/51Y
+subcognitive/51Y
cognizable/5
cognizance/1AM
cognizant/5
@@ -22620,6 +22623,7 @@ executive/51SM
executor/1MS
executrices/1
executrix/1M
+executable/1MS
exegeses/1
exegesis/1M
exegetic/5
@@ -49655,3 +49659,30 @@ Wikilink/MS1
stacktrace/SM1
scrollbar/1SM
break-up/1SM
+sweetgrass/SM
+PowerShell/SM
+WebSocket/SM
+BlasterHacks/SM
+Goleman/SM
+Kahneman/SM
+Graphviz/SM
+PTSD/SM
+Anker/SM
+wikilink/SM
+labriola/SM
+sioyek/SM
+pandoc/SM
+Minhaj/SM
+Vaadin/SM
+CI/SM
+archytas/SM
+Qin/SM
+occipital/SM
+onboarding/SM
+webpage/SM
+Holmdel/SM
+Grandey/SM
+Foddy/SM
+Hasan/SM
+Sharman/SM
+Labriola/SM
diff --git a/justfile b/justfile
index 3e9df5e26..280936fa8 100644
--- a/justfile
+++ b/justfile
@@ -105,3 +105,31 @@ parse file:
lint file:
cargo run --bin harper-cli -- lint {{file}}
+
+# Add a noun to Harper's curated dictionary.
+addnoun noun:
+ #! /bin/bash
+ DICT_FILE=./harper-core/dictionary.dict
+
+ cat $DICT_FILE | grep {{noun}}
+
+ if [ $? -eq 0 ]
+ then
+ echo "That noun may already be in the dictionary."
+ exit 0
+ fi
+
+ echo "{{noun}}/SM" >> $DICT_FILE
+
+# Search Harper's curated dictionary for a specific word
+searchdictfor word:
+ cargo run --bin harper-cli -- words | rg {{word}}
+
+# Find words in the user's `harper-ls/dictionary.txt` for words already in the curated dictionary.
+userdictoverlap:
+ #! /bin/bash
+ USER_DICT_FILE="$HOME/.config/harper-ls/dictionary.txt"
+
+ while read -r line; do
+ just searchdictfor $line 2> /dev/null
+ done < $USER_DICT_FILE