Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
refactor: nominal phrase but compound noun
hippietraila348c197dcbc
diff --git a/harper-core/src/linting/compound_nominals/general_compound_nominals.rs b/harper-core/src/linting/compound_nouns/general_compound_nominals.rssimilarity index 95%rename from harper-core/src/linting/compound_nominals/general_compound_nominals.rsrename to harper-core/src/linting/compound_nouns/general_compound_nominals.rsindex 1e41b81cc..11263f7b8 100644--- a/harper-core/src/linting/compound_nominals/general_compound_nominals.rs+++ b/harper-core/src/linting/compound_nouns/general_compound_nominals.rs@@ -12,12 +12,12 @@ use crate::{};/// Covers the general cases of accidentally split compound nouns.-pub struct GeneralCompoundNominals {+pub struct GeneralCompoundNouns {pattern: Box<dyn Pattern>,split_pattern: Lrc<SplitCompoundWord>,}-impl Default for GeneralCompoundNominals {+impl Default for GeneralCompoundNouns {fn default() -> Self {let exceptions_pattern = SequencePattern::default().then(|tok: &Token, _: &[char]| {@@ -64,7 +64,7 @@ impl Default for GeneralCompoundNominals {}}-impl PatternLinter for GeneralCompoundNominals {+impl PatternLinter for GeneralCompoundNouns {fn pattern(&self) -> &dyn Pattern {self.pattern.as_ref()}diff --git a/harper-core/src/linting/compound_nominals/implied_action_compound_nominals.rs b/harper-core/src/linting/compound_nouns/implied_action_compound_nominals.rssimilarity index 92%rename from harper-core/src/linting/compound_nominals/implied_action_compound_nominals.rsrename to harper-core/src/linting/compound_nouns/implied_action_compound_nominals.rsindex 6cbed1860..01a46712b 100644--- a/harper-core/src/linting/compound_nominals/implied_action_compound_nominals.rs+++ b/harper-core/src/linting/compound_nouns/implied_action_compound_nominals.rs@@ -11,12 +11,12 @@ use crate::{/// Looks for closed compound nominals which can be condensed due to their position after a/// possessive nominal (which implies ownership).-pub struct ImpliedActionCompoundNominals {+pub struct ImpliedActionCompoundNouns {pattern: Box<dyn Pattern>,split_pattern: Lrc<SplitCompoundWord>,}-impl Default for ImpliedActionCompoundNominals {+impl Default for ImpliedActionCompoundNouns {fn default() -> Self {let split_pattern = Lrc::new(SplitCompoundWord::new(|meta| meta.is_nominal()));let pattern = SequencePattern::default()@@ -33,7 +33,7 @@ impl Default for ImpliedActionCompoundNominals {}}-impl PatternLinter for ImpliedActionCompoundNominals {+impl PatternLinter for ImpliedActionCompoundNouns {fn pattern(&self) -> &dyn Pattern {self.pattern.as_ref()}diff --git a/harper-core/src/linting/compound_nominals/implied_ownership_compound_nominals.rs b/harper-core/src/linting/compound_nouns/implied_ownership_compound_nominals.rssimilarity index 91%rename from harper-core/src/linting/compound_nominals/implied_ownership_compound_nominals.rsrename to harper-core/src/linting/compound_nouns/implied_ownership_compound_nominals.rsindex d7d3cd558..98feff505 100644--- a/harper-core/src/linting/compound_nominals/implied_ownership_compound_nominals.rs+++ b/harper-core/src/linting/compound_nouns/implied_ownership_compound_nominals.rs@@ -11,12 +11,12 @@ use crate::{/// Looks for closed compound nouns which can be condensed due to their position after a/// possessive noun (which implies ownership).-pub struct ImpliedOwnershipCompoundNominals {+pub struct ImpliedOwnershipCompoundNouns {pattern: Box<dyn Pattern>,split_pattern: Lrc<SplitCompoundWord>,}-impl Default for ImpliedOwnershipCompoundNominals {+impl Default for ImpliedOwnershipCompoundNouns {fn default() -> Self {let split_pattern = Lrc::new(SplitCompoundWord::new(|meta| meta.is_nominal()));let pattern = SequencePattern::default()@@ -31,7 +31,7 @@ impl Default for ImpliedOwnershipCompoundNominals {}}-impl PatternLinter for ImpliedOwnershipCompoundNominals {+impl PatternLinter for ImpliedOwnershipCompoundNouns {fn pattern(&self) -> &dyn Pattern {self.pattern.as_ref()}diff --git a/harper-core/src/linting/compound_nominals/mod.rs b/harper-core/src/linting/compound_nouns/mod.rssimilarity index 67%rename from harper-core/src/linting/compound_nominals/mod.rsrename to harper-core/src/linting/compound_nouns/mod.rsindex 03b3a2761..06998eb6f 100644--- a/harper-core/src/linting/compound_nominals/mod.rs+++ b/harper-core/src/linting/compound_nouns/mod.rs@@ -4,265 +4,265 @@ mod implied_ownership_compound_nominals;use super::{Lint, LintKind, Suggestion, merge_linters::merge_linters};-use general_compound_nominals::GeneralCompoundNominals;-use implied_action_compound_nominals::ImpliedActionCompoundNominals;-use implied_ownership_compound_nominals::ImpliedOwnershipCompoundNominals;+use general_compound_nominals::GeneralCompoundNouns;+use implied_action_compound_nominals::ImpliedActionCompoundNouns;+use implied_ownership_compound_nominals::ImpliedOwnershipCompoundNouns;-merge_linters!(CompoundNominals => GeneralCompoundNominals, ImpliedOwnershipCompoundNominals, ImpliedActionCompoundNominals => "Detects compound nouns split by a space and suggests merging them when both parts form a valid noun." );+merge_linters!(CompoundNouns => GeneralCompoundNouns, ImpliedOwnershipCompoundNouns, ImpliedActionCompoundNouns => "Detects compound nouns split by a space and suggests merging them when both parts form a valid noun." );#[cfg(test)]mod tests {- use super::CompoundNominals;+ use super::CompoundNouns;use crate::linting::tests::{assert_lint_count, assert_suggestion_result};#[test]fn web_cam() {let test_sentence = "The web cam captured a stunning image.";let expected = "The webcam captured a stunning image.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn note_book() {let test_sentence = "She always carries a note book to jot down ideas.";let expected = "She always carries a notebook to jot down ideas.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn mother_board() {let test_sentence = "After the upgrade, the mother board was replaced.";let expected = "After the upgrade, the motherboard was replaced.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn smart_phone() {let test_sentence = "He bought a new smart phone last week.";let expected = "He bought a new smartphone last week.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn firm_ware() {let test_sentence = "The device's firm ware was updated overnight.";let expected = "The device's firmware was updated overnight.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn back_plane() {let test_sentence = "A reliable back plane is essential for high-speed data transfer.";let expected = "A reliable backplane is essential for high-speed data transfer.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn spread_sheet() {let test_sentence = "The accountant reviewed the spread sheet carefully.";let expected = "The accountant reviewed the spreadsheet carefully.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn side_bar() {let test_sentence = "The website's side bar offers quick navigation links.";let expected = "The website's sidebar offers quick navigation links.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn back_pack() {let test_sentence = "I packed my books in my back pack before leaving.";let expected = "I packed my books in my backpack before leaving.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn cup_board() {let test_sentence = "She stored the dishes in the old cup board.";let expected = "She stored the dishes in the old cupboard.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn key_board() {let test_sentence = "My key board stopped working during the meeting.";let expected = "My keyboard stopped working during the meeting.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn touch_screen() {let test_sentence = "The device features a responsive touch screen.";let expected = "The device features a responsive touchscreen.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn head_set() {let test_sentence = "He bought a new head set for his workouts.";let expected = "He bought a new headset for his workouts.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn frame_work() {let test_sentence = "The frame work of the app was built with care.";let expected = "The framework of the app was built with care.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn touch_pad() {let test_sentence = "The touch pad on my laptop is very sensitive.";let expected = "The touchpad on my laptop is very sensitive.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn micro_processor() {let test_sentence = "This micro processor is among the fastest available.";let expected = "This microprocessor is among the fastest available.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn head_phone() {let test_sentence = "I lost my head phone at the gym.";let expected = "I lost my headphone at the gym.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn micro_services() {let test_sentence = "Our architecture now relies on micro services.";let expected = "Our architecture now relies on microservices.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn dash_board() {let test_sentence = "The dash board shows real-time analytics.";let expected = "The dashboard shows real-time analytics.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn site_map() {let test_sentence = "A site map is provided at the footer of the website.";let expected = "A sitemap is provided at the footer of the website.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn fire_wall() {let test_sentence = "A robust fire wall is essential for network security.";let expected = "A robust firewall is essential for network security.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn bit_stream() {let test_sentence = "The bit stream was interrupted during transmission.";let expected = "The bitstream was interrupted during transmission.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn block_chain() {let test_sentence = "The block chain is revolutionizing the financial sector.";let expected = "The blockchain is revolutionizing the financial sector.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn thumb_nail() {let test_sentence = "I saved the image as a thumb nail.";let expected = "I saved the image as a thumbnail.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn bath_room() {let test_sentence = "They remodeled the bath room entirely.";let expected = "They remodeled the bathroom entirely.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn every_one() {let test_sentence = "Every one should have access to quality education.";let expected = "Everyone should have access to quality education.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn play_ground() {let test_sentence = "The kids spent the afternoon at the play ground.";let expected = "The kids spent the afternoon at the playground.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn run_way() {let test_sentence = "The airplane taxied along the run way.";let expected = "The airplane taxied along the runway.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn cyber_space() {let test_sentence = "Hackers roam the cyber space freely.";let expected = "Hackers roam the cyberspace freely.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn cyber_attack() {let test_sentence = "The network was hit by a cyber attack.";let expected = "The network was hit by a cyberattack.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn web_socket() {let test_sentence = "Real-time updates are sent via a web socket.";let expected = "Real-time updates are sent via a websocket.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn finger_print() {let test_sentence = "The detective collected a finger print as evidence.";let expected = "The detective collected a fingerprint as evidence.";- assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);+ assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}#[test]fn got_is_not_possessive() {- assert_lint_count("I got here by car...", CompoundNominals::default(), 0);+ assert_lint_count("I got here by car...", CompoundNouns::default(), 0);}#[test]fn allow_issue_662() {assert_lint_count("They are as old as *modern* computers ",- CompoundNominals::default(),+ CompoundNouns::default(),0,);}#[test]fn allow_issue_661() {- assert_lint_count("I may be wrong.", CompoundNominals::default(), 0);+ assert_lint_count("I may be wrong.", CompoundNouns::default(), 0);}#[test]fn allow_issue_704() {assert_lint_count("Here are some ways to do that:",- CompoundNominals::default(),+ CompoundNouns::default(),0,);}@@ -271,7 +271,7 @@ mod tests {fn allows_issue_721() {assert_lint_count("So if you adjust any one of these adjusters that can have a negative or a positive effect.",- CompoundNominals::default(),+ CompoundNouns::default(),0,);}@@ -280,7 +280,7 @@ mod tests {fn allows_678() {assert_lint_count("they can't catch all the bugs.",- CompoundNominals::default(),+ CompoundNouns::default(),0,);}diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rsindex a268d850d..92ec0f976 100644--- a/harper-core/src/linting/lint_group.rs+++ b/harper-core/src/linting/lint_group.rs@@ -13,7 +13,7 @@ use super::back_in_the_day::BackInTheDay;use super::boring_words::BoringWords;use super::capitalize_personal_pronouns::CapitalizePersonalPronouns;use super::chock_full::ChockFull;-use super::compound_nominals::CompoundNominals;+use super::compound_nouns::CompoundNouns;use super::correct_number_suffix::CorrectNumberSuffix;use super::despite_of::DespiteOf;use super::dot_initialisms::DotInitialisms;@@ -215,7 +215,7 @@ impl LintGroup {insert_struct_rule!(HopHope, true);insert_struct_rule!(Hereby, true);insert_struct_rule!(Likewise, true);- insert_struct_rule!(CompoundNominals, true);+ insert_struct_rule!(CompoundNouns, true);insert_struct_rule!(Nobody, true);insert_struct_rule!(Whereas, true);insert_struct_rule!(PossessiveYour, true);diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rsindex 8c9e7c031..223f14733 100644--- a/harper-core/src/linting/mod.rs+++ b/harper-core/src/linting/mod.rs@@ -9,7 +9,7 @@ mod boring_words;mod capitalize_personal_pronouns;mod chock_full;mod closed_compounds;-mod compound_nominals;+mod compound_nouns;mod correct_number_suffix;mod currency_placement;mod dashes;@@ -68,7 +68,7 @@ pub use back_in_the_day::BackInTheDay;pub use boring_words::BoringWords;pub use capitalize_personal_pronouns::CapitalizePersonalPronouns;pub use chock_full::ChockFull;-pub use compound_nominals::CompoundNominals;+pub use compound_nouns::CompoundNouns;pub use correct_number_suffix::CorrectNumberSuffix;pub use currency_placement::CurrencyPlacement;pub use despite_of::DespiteOf;diff --git a/harper-typst/src/lib.rs b/harper-typst/src/lib.rsindex 2f3436830..bd9ed1bbf 100644--- a/harper-typst/src/lib.rs+++ b/harper-typst/src/lib.rs@@ -39,9 +39,7 @@ mod tests {use ordered_float::OrderedFloat;use super::Typst;- // use harper_core::{Document, NominalData, Number, Punctuation, TokenKind, WordMetadata};use harper_core::{Document, NounData, Number, Punctuation, TokenKind, WordMetadata};- // use harper_core::{Document, Number, Punctuation, TokenKind, WordMetadata};#[test]fn number() {