Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
Added matching rules + improved demo + fixed layout issue in web client
Elijah Potter69fefb24106d
diff --git a/demo.md b/demo.mdindex 640a42875..3fbdd5e7c 100644--- a/demo.md+++ b/demo.md@@ -2,6 +2,10 @@ Harper is a language checker for artists. it can detectimproper capitalization and misspelled words. There are some cases,where the the standard grammar checkers don't cut it.-That's where Harper comes in handy.+That s where Harper comes in handy.-kid regards, Elijah+Harper works everywhere, even offline. Since you r data never leaves your device,+you don't ned to worry aout us selling it or using it to train LLMs.++The best part: Harper can give you feedback instantly.+For most documents, Harper can serve up suggestions in under 10 ms.diff --git a/harper-core/src/linting/matcher.rs b/harper-core/src/linting/matcher.rsindex 0ca6ef926..ac5beffcb 100644--- a/harper-core/src/linting/matcher.rs+++ b/harper-core/src/linting/matcher.rs@@ -38,6 +38,12 @@ macro_rules! pt {content: Some($str.chars().collect()),}};+ (Period) => {+ PatternToken {+ kind: TokenKind::Punctuation(Punctuation::Period),+ content: None,+ }+ };(Hyphen) => {PatternToken {kind: TokenKind::Punctuation(Punctuation::Hyphen),@@ -122,13 +128,23 @@ impl Matcher {"more","then" => "more than","gong","to" => "going to","then","others" => "than others",+ "Then","others" => "than others","then","before" => "than before",+ "Then","before" => "than before","then","last","week" => "than last week","then","her" => "than her","then","hers" => "than hers","then","him" => "than him","then","his" => "than his",- "simply","grammatical" => "simple grammatical"+ "simply","grammatical" => "simple grammatical",+ "you","r" => "your",+ "that","s" => "that's",+ "That","s" => "that's",+ "that","s" => "that is",+ "That","s" => "that is",+ "ms" => "milliseconds",+ "LLM" => "large language model",+ "LLMs" => "large language models"};triggers.push(Rule {@@ -136,6 +152,23 @@ impl Matcher {replace_with: vecword!("break-up"),});+ triggers.push(Rule {+ pattern: vec![pt!("L"), pt!(Period), pt!("L"), pt!(Period), pt!("M")],+ replace_with: vecword!("large language model"),+ });++ triggers.push(Rule {+ pattern: vec![+ pt!("L"),+ pt!(Period),+ pt!("L"),+ pt!(Period),+ pt!("M"),+ pt!(Period),+ ],+ replace_with: vecword!("large language model"),+ });+Self { triggers }}}diff --git a/harper-wasm/Cargo.toml b/harper-wasm/Cargo.tomlindex 5d88dd57e..11554e347 100644--- a/harper-wasm/Cargo.toml+++ b/harper-wasm/Cargo.toml@@ -9,7 +9,7 @@ publish = falsecrate-type = ["cdylib", "rlib"][profile.release]-opt-level = "s"+opt-level = 3strip = true[dependencies]diff --git a/web/src/lib/Editor.svelte b/web/src/lib/Editor.svelteindex 49816ff53..4573e3f6b 100644--- a/web/src/lib/Editor.svelte+++ b/web/src/lib/Editor.svelte@@ -41,7 +41,7 @@><textareabind:this={editor}- class="w-full m-0 rounded-none p-0 z-0 bg-transparent border-none text-lg resize-none focus:border-0"+ class="w-full text-nowrap m-0 rounded-none p-0 z-0 bg-transparent overflow-hidden border-none text-lg resize-none focus:border-0"spellcheck="false"style={`grid-row: 1; grid-column: 1; height: ${boxHeight}px`}on:keydown={() => (focused = undefined)}diff --git a/web/src/lib/Graph.svelte b/web/src/lib/Graph.sveltenew file mode 100644index 000000000..e69de29bbdiff --git a/web/src/lib/Underlines.svelte b/web/src/lib/Underlines.svelteindex 070c07171..4f9bbeea2 100644--- a/web/src/lib/Underlines.svelte+++ b/web/src/lib/Underlines.svelte@@ -83,7 +83,7 @@</script><div class="grid">- <div class="p-0 m-0 indent-0 text-transparent" style="grid-row: 1; grid-column: 1">+ <div class="p-0 m-0 text-nowrap indent-0 text-transparent" style="grid-row: 1; grid-column: 1">{#each modified as chunk}{#if chunk == null}<br />diff --git a/web/src/lib/analysis.ts b/web/src/lib/analysis.tsindex 263f2cb8b..374525b17 100644--- a/web/src/lib/analysis.ts+++ b/web/src/lib/analysis.ts@@ -81,7 +81,6 @@ export function spanContent(span: Span, source: string): string {}export async function lintText(text: string, useWasm = defaultUseWasm): Promise<Lint[]> {- console.time('lint');let lints;if (useWasm) {@@ -107,7 +106,6 @@ export async function lintText(text: string, useWasm = defaultUseWasm): Promise<// The `Underlines` component assumes the lints do not overlap.lints = removeOverlaps(lints);- console.timeEnd('lint');return lints;}diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelteindex ccc58862a..23faf776e 100644--- a/web/src/routes/+page.svelte+++ b/web/src/routes/+page.svelte@@ -1,5 +1,6 @@<script>import Editor from '$lib/Editor.svelte';+ import Graph from '$lib/Graph.svelte';let width = window.innerWidth;