Skip to content

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

refactor: noun to nominal update

hippietrail830a23983b4c
diff --git a/harper-core/affixes.json b/harper-core/affixes.json
index ab65899c1..c20bb5296 100644
--- a/harper-core/affixes.json
+++ b/harper-core/affixes.json
@@ -285,12 +285,12 @@
}
],
"adds_metadata": {
- "noun": {
+ "nominal": {
"is_possessive": true
}
},
"gifts_metadata": {
- "noun": {}
+ "nominal": {}
}
},
"F": {
@@ -358,7 +358,7 @@
}
],
"adds_metadata": {
- "noun": {
+ "nominal": {
"is_plural": true
}
},
@@ -415,7 +415,7 @@
],
"adds_metadata": {
"verb": {},
- "noun": null
+ "nominal": null
},
"gifts_metadata": {}
},
@@ -511,7 +511,7 @@
"replacements": [],
"adds_metadata": {},
"gifts_metadata": {
- "noun": {
+ "nominal": {
"is_plural": false
}
}
@@ -523,7 +523,7 @@
"replacements": [],
"adds_metadata": {},
"gifts_metadata": {
- "noun": {
+ "nominal": {
"is_proper": true
}
}
@@ -589,7 +589,7 @@
"replacements": [],
"adds_metadata": {},
"gifts_metadata": {
- "noun": {
+ "nominal": {
"is_pronoun": true
}
}
@@ -601,7 +601,7 @@
"replacements": [],
"adds_metadata": {},
"gifts_metadata": {
- "noun": {
+ "nominal": {
"is_plural": true
}
}
diff --git a/harper-core/src/lib.rs b/harper-core/src/lib.rs
index e522dd8f3..d357d804c 100644
--- a/harper-core/src/lib.rs
+++ b/harper-core/src/lib.rs
@@ -45,7 +45,7 @@ pub use token::Token;
pub use token_kind::TokenKind;
pub use token_string_ext::TokenStringExt;
pub use vec_ext::VecExt;
-pub use word_metadata::{AdverbData, ConjunctionData, NounData, Tense, VerbData, WordMetadata};
+pub use word_metadata::{AdverbData, ConjunctionData, NominalData, Tense, VerbData, WordMetadata};
/// A utility function that removes overlapping lints in a vector,
/// keeping the more important ones.
diff --git a/harper-core/src/linting/capitalize_personal_pronouns.rs b/harper-core/src/linting/capitalize_personal_pronouns.rs
index 3a5115cd3..dd7251821 100644
--- a/harper-core/src/linting/capitalize_personal_pronouns.rs
+++ b/harper-core/src/linting/capitalize_personal_pronouns.rs
@@ -1,4 +1,4 @@
-use crate::{NounData, TokenKind, TokenStringExt, WordMetadata};
+use crate::{NominalData, TokenKind, TokenStringExt, WordMetadata};
use super::{Lint, LintKind, Linter, Suggestion};
@@ -12,8 +12,8 @@ impl Linter for CapitalizePersonalPronouns {
for tok in document.iter_words() {
if let TokenKind::Word(Some(WordMetadata {
- noun:
- Some(NounData {
+ nominal:
+ Some(NominalData {
is_pronoun: Some(true),
..
}),
diff --git a/harper-core/src/linting/compound_nouns/general_compound_nouns.rs b/harper-core/src/linting/compound_nominals/general_compound_nominals.rs
similarity index 92%
rename from harper-core/src/linting/compound_nouns/general_compound_nouns.rs
rename to harper-core/src/linting/compound_nominals/general_compound_nominals.rs
index f1c795d5a..8f55ecb10 100644
--- a/harper-core/src/linting/compound_nouns/general_compound_nouns.rs
+++ b/harper-core/src/linting/compound_nominals/general_compound_nominals.rs
@@ -12,12 +12,12 @@ use crate::{
};
/// Covers the general cases of accidentally split compound nouns.
-pub struct GeneralCompoundNouns {
+pub struct GeneralCompoundNominals {
pattern: Box<dyn Pattern>,
split_pattern: Lrc<SplitCompoundWord>,
}
-impl Default for GeneralCompoundNouns {
+impl Default for GeneralCompoundNominals {
fn default() -> Self {
let exceptions_pattern = SequencePattern::default()
.then(|tok: &Token, _: &[char]| {
@@ -37,7 +37,7 @@ impl Default for GeneralCompoundNouns {
});
let split_pattern = Lrc::new(SplitCompoundWord::new(|meta| {
- meta.is_noun() && !meta.is_adjective()
+ meta.is_nominal() && !meta.is_adjective()
}));
let mut pattern = All::default();
@@ -51,7 +51,7 @@ impl Default for GeneralCompoundNouns {
}
}
-impl PatternLinter for GeneralCompoundNouns {
+impl PatternLinter for GeneralCompoundNominals {
fn pattern(&self) -> &dyn Pattern {
self.pattern.as_ref()
}
diff --git a/harper-core/src/linting/compound_nouns/implied_ownership_compound_nouns.rs b/harper-core/src/linting/compound_nominals/implied_ownership_compound_nominals.rs
similarity index 88%
rename from harper-core/src/linting/compound_nouns/implied_ownership_compound_nouns.rs
rename to harper-core/src/linting/compound_nominals/implied_ownership_compound_nominals.rs
index 8a9294b5e..d7d3cd558 100644
--- a/harper-core/src/linting/compound_nouns/implied_ownership_compound_nouns.rs
+++ b/harper-core/src/linting/compound_nominals/implied_ownership_compound_nominals.rs
@@ -11,16 +11,16 @@ use crate::{
/// Looks for closed compound nouns which can be condensed due to their position after a
/// possessive noun (which implies ownership).
-pub struct ImpliedOwnershipCompoundNouns {
+pub struct ImpliedOwnershipCompoundNominals {
pattern: Box<dyn Pattern>,
split_pattern: Lrc<SplitCompoundWord>,
}
-impl Default for ImpliedOwnershipCompoundNouns {
+impl Default for ImpliedOwnershipCompoundNominals {
fn default() -> Self {
- let split_pattern = Lrc::new(SplitCompoundWord::new(|meta| meta.is_noun()));
+ let split_pattern = Lrc::new(SplitCompoundWord::new(|meta| meta.is_nominal()));
let pattern = SequencePattern::default()
- .then_possessive_noun()
+ .then_possessive_nominal()
.then_whitespace()
.then(split_pattern.clone());
@@ -31,7 +31,7 @@ impl Default for ImpliedOwnershipCompoundNouns {
}
}
-impl PatternLinter for ImpliedOwnershipCompoundNouns {
+impl PatternLinter for ImpliedOwnershipCompoundNominals {
fn pattern(&self) -> &dyn Pattern {
self.pattern.as_ref()
}
diff --git a/harper-core/src/linting/compound_nouns/mod.rs b/harper-core/src/linting/compound_nominals/mod.rs
similarity index 65%
rename from harper-core/src/linting/compound_nouns/mod.rs
rename to harper-core/src/linting/compound_nominals/mod.rs
index 7f5d95410..14fa72704 100644
--- a/harper-core/src/linting/compound_nouns/mod.rs
+++ b/harper-core/src/linting/compound_nominals/mod.rs
@@ -1,266 +1,266 @@
-mod general_compound_nouns;
-mod implied_ownership_compound_nouns;
+mod general_compound_nominals;
+mod implied_ownership_compound_nominals;
use super::{Lint, LintKind, Suggestion, merge_linters::merge_linters};
-use general_compound_nouns::GeneralCompoundNouns;
-use implied_ownership_compound_nouns::ImpliedOwnershipCompoundNouns;
+use general_compound_nominals::GeneralCompoundNominals;
+use implied_ownership_compound_nominals::ImpliedOwnershipCompoundNominals;
-merge_linters!(CompoundNouns => GeneralCompoundNouns, ImpliedOwnershipCompoundNouns => "Detects compound nouns split by a space and suggests merging them when both parts form a valid noun." );
+merge_linters!(CompoundNominals => GeneralCompoundNominals, ImpliedOwnershipCompoundNominals => "Detects compound nouns split by a space and suggests merging them when both parts form a valid noun." );
#[cfg(test)]
mod tests {
- use super::CompoundNouns;
+ use super::CompoundNominals;
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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::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, CompoundNouns::default(), expected);
+ assert_suggestion_result(test_sentence, CompoundNominals::default(), expected);
}
#[test]
fn got_is_not_possessive() {
- assert_lint_count("I got here by car...", CompoundNouns::default(), 0);
+ assert_lint_count("I got here by car...", CompoundNominals::default(), 0);
}
#[test]
fn allow_issue_662() {
assert_lint_count(
"They are as old as *modern* computers ",
- CompoundNouns::default(),
+ CompoundNominals::default(),
0,
);
}
#[test]
fn allow_issue_661() {
- assert_lint_count("I may be wrong.", CompoundNouns::default(), 0);
+ assert_lint_count("I may be wrong.", CompoundNominals::default(), 0);
}
#[test]
fn allow_issue_704() {
assert_lint_count(
"Here are some ways to do that:",
- CompoundNouns::default(),
+ CompoundNominals::default(),
0,
);
}
diff --git a/harper-core/src/linting/hyphenate_number_day.rs b/harper-core/src/linting/hyphenate_number_day.rs
index b87105eb1..8d6cfd684 100644
--- a/harper-core/src/linting/hyphenate_number_day.rs
+++ b/harper-core/src/linting/hyphenate_number_day.rs
@@ -1,6 +1,6 @@
use crate::{
Token,
- patterns::{EitherPattern, NounPhrase, Pattern, SequencePattern},
+ patterns::{EitherPattern, NominalPhrase, Pattern, SequencePattern},
};
use super::{Lint, LintKind, PatternLinter, Suggestion};
@@ -19,14 +19,14 @@ impl Default for HyphenateNumberDay {
Box::new(
SequencePattern::default()
.then_whitespace()
- .then(NounPhrase),
+ .then(NominalPhrase),
),
Box::new(
SequencePattern::default()
.then_hyphen()
.then_adjective()
.then_whitespace()
- .then(NounPhrase),
+ .then(NominalPhrase),
),
]));
diff --git a/harper-core/src/linting/left_right_hand.rs b/harper-core/src/linting/left_right_hand.rs
index 0d641c025..636cdabfe 100644
--- a/harper-core/src/linting/left_right_hand.rs
+++ b/harper-core/src/linting/left_right_hand.rs
@@ -16,7 +16,7 @@ impl Default for LeftRightHand {
.then_whitespace()
.t_aco("hand")
.then_whitespace()
- .then_noun();
+ .then_nominal();
Self {
pattern: Box::new(pattern),
@@ -71,7 +71,7 @@ mod tests {
}
#[test]
- fn does_not_correct_noun_usage() {
+ fn does_not_correct_nominal_usage() {
assert_suggestion_result(
"She raised her right hand.",
LeftRightHand::default(),
diff --git a/harper-core/src/linting/likewise.rs b/harper-core/src/linting/likewise.rs
index 0592e813a..195316861 100644
--- a/harper-core/src/linting/likewise.rs
+++ b/harper-core/src/linting/likewise.rs
@@ -22,7 +22,7 @@ impl Default for Likewise {
.then_whitespace()
.then_anything()
.then_whitespace()
- .then_noun(),
+ .then_nominal(),
)));
Self {
diff --git a/harper-core/src/linting/linking_verbs.rs b/harper-core/src/linting/linking_verbs.rs
index f5f32ff17..269fc92c8 100644
--- a/harper-core/src/linting/linking_verbs.rs
+++ b/harper-core/src/linting/linking_verbs.rs
@@ -21,7 +21,7 @@ impl Linter for LinkingVerbs {
.kind
.as_word()
.unwrap()
- .is_some_and(|m| m.is_noun())
+ .is_some_and(|m| m.is_nominal())
{
output.push(Lint {
span: linking_verb.span,
diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rs
index 9e68b7703..15e62eba3 100644
--- a/harper-core/src/linting/lint_group.rs
+++ b/harper-core/src/linting/lint_group.rs
@@ -12,7 +12,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_nouns::CompoundNouns;
+use super::compound_nominals::CompoundNominals;
use super::correct_number_suffix::CorrectNumberSuffix;
use super::despite_of::DespiteOf;
use super::dot_initialisms::DotInitialisms;
@@ -36,7 +36,7 @@ use super::pique_interest::PiqueInterest;
use super::plural_conjugate::PluralConjugate;
use super::possessive_your::PossessiveYour;
use super::pronoun_contraction::PronounContraction;
-use super::proper_noun_capitalization_linters;
+use super::proper_nominal_capitalization_linters;
use super::repeated_words::RepeatedWords;
use super::sentence_capitalization::SentenceCapitalization;
use super::somewhat_something::SomewhatSomething;
@@ -189,7 +189,7 @@ impl LintGroup {
}
out.merge_from(&mut phrase_corrections::lint_group());
- out.merge_from(&mut proper_noun_capitalization_linters::lint_group(
+ out.merge_from(&mut proper_nominal_capitalization_linters::lint_group(
dictionary.clone(),
));
out.merge_from(&mut closed_compounds::lint_group());
@@ -206,7 +206,7 @@ impl LintGroup {
insert_struct_rule!(HopHope, true);
insert_struct_rule!(Hereby, true);
insert_struct_rule!(Likewise, true);
- insert_struct_rule!(CompoundNouns, true);
+ insert_struct_rule!(CompoundNominals, 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.rs
index e04df095b..8c9e7c031 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_nouns;
+mod compound_nominals;
mod correct_number_suffix;
mod currency_placement;
mod dashes;
@@ -44,7 +44,7 @@ mod pique_interest;
mod plural_conjugate;
mod possessive_your;
mod pronoun_contraction;
-mod proper_noun_capitalization_linters;
+mod proper_nominal_capitalization_linters;
mod repeated_words;
mod sentence_capitalization;
mod somewhat_something;
@@ -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_nouns::CompoundNouns;
+pub use compound_nominals::CompoundNominals;
pub use correct_number_suffix::CorrectNumberSuffix;
pub use currency_placement::CurrencyPlacement;
pub use despite_of::DespiteOf;
diff --git a/harper-core/src/linting/no_oxford_comma.rs b/harper-core/src/linting/no_oxford_comma.rs
index f35603f4b..be58c6228 100644
--- a/harper-core/src/linting/no_oxford_comma.rs
+++ b/harper-core/src/linting/no_oxford_comma.rs
@@ -1,6 +1,6 @@
use crate::{
Document, Token, TokenStringExt,
- patterns::{NounPhrase, Pattern, SequencePattern, WordSet},
+ patterns::{NominalPhrase, Pattern, SequencePattern, WordSet},
};
use super::{Lint, LintKind, Linter, Suggestion};
@@ -15,11 +15,11 @@ impl NoOxfordComma {
pattern: {
let this = {
let this = SequencePattern::default();
- this.then(NounPhrase)
+ this.then(NominalPhrase)
}
.then_comma()
.then_whitespace();
- this.then(NounPhrase)
+ this.then(NominalPhrase)
}
.then_comma()
.then_whitespace()
diff --git a/harper-core/src/linting/oxford_comma.rs b/harper-core/src/linting/oxford_comma.rs
index ccf2868fc..7e7db0a41 100644
--- a/harper-core/src/linting/oxford_comma.rs
+++ b/harper-core/src/linting/oxford_comma.rs
@@ -1,6 +1,6 @@
use crate::{
Document, Token, TokenStringExt,
- patterns::{NounPhrase, Pattern, SequencePattern, WordSet},
+ patterns::{NominalPhrase, Pattern, SequencePattern, WordSet},
};
use super::{Lint, LintKind, Linter, Suggestion};
@@ -16,16 +16,16 @@ impl OxfordComma {
let this = {
let this = SequencePattern::default().then_one_or_more(Box::new(
SequencePattern::default()
- .then(NounPhrase)
+ .then(NominalPhrase)
.then_comma()
.then_whitespace(),
));
- this.then(NounPhrase)
+ this.then(NominalPhrase)
}
.then_whitespace()
.then(WordSet::new(&["and", "or", "nor"]))
.then_whitespace();
- this.then(NounPhrase)
+ this.then(NominalPhrase)
},
}
}
diff --git a/harper-core/src/linting/plural_conjugate.rs b/harper-core/src/linting/plural_conjugate.rs
index 0fd7ac4dd..92f00acea 100644
--- a/harper-core/src/linting/plural_conjugate.rs
+++ b/harper-core/src/linting/plural_conjugate.rs
@@ -12,13 +12,13 @@ pub struct PluralConjugate {
impl Default for PluralConjugate {
fn default() -> Self {
let plural_case = SequencePattern::default()
- .then_plural_noun()
+ .then_plural_nominal()
.then_whitespace()
.then_exact_word("is");
let non_plural_case = SequencePattern::default()
.then(|tok: &Token, _source: &[char]| {
- tok.kind.is_not_plural_noun() && tok.kind.is_noun()
+ tok.kind.is_not_plural_nominal() && tok.kind.is_nominal()
})
.then_whitespace()
.then_exact_word("are");
@@ -37,7 +37,7 @@ impl PatternLinter for PluralConjugate {
}
fn match_to_lint(&self, matched_tokens: &[Token], _source: &[char]) -> Option<Lint> {
- let should_be_plural = matched_tokens.first()?.kind.is_plural_noun();
+ let should_be_plural = matched_tokens.first()?.kind.is_plural_nominal();
let sug = if should_be_plural {
vec!['a', 'r', 'e']
diff --git a/harper-core/src/linting/possessive_your.rs b/harper-core/src/linting/possessive_your.rs
index 06a2416f0..4cf012548 100644
--- a/harper-core/src/linting/possessive_your.rs
+++ b/harper-core/src/linting/possessive_your.rs
@@ -15,7 +15,7 @@ impl Default for PossessiveYour {
SequencePattern::aco("you")
.then_whitespace()
.then(|tok: &Token, _source: &[char]| {
- tok.kind.is_noun() && !tok.kind.is_verb() && !tok.kind.is_adverb()
+ tok.kind.is_nominal() && !tok.kind.is_verb() && !tok.kind.is_adverb()
});
Self {
diff --git a/harper-core/src/linting/pronoun_contraction/avoid_contraction.rs b/harper-core/src/linting/pronoun_contraction/avoid_contraction.rs
index 8f950309b..060cca2c9 100644
--- a/harper-core/src/linting/pronoun_contraction/avoid_contraction.rs
+++ b/harper-core/src/linting/pronoun_contraction/avoid_contraction.rs
@@ -11,9 +11,9 @@ pub struct AvoidContraction {
impl Default for AvoidContraction {
fn default() -> Self {
- let pattern = SequencePattern::aco("you're")
- .then_whitespace()
- .then(|tok: &Token, _source: &[char]| tok.kind.is_noun() && !tok.kind.is_adjective());
+ let pattern = SequencePattern::aco("you're").then_whitespace().then(
+ |tok: &Token, _source: &[char]| tok.kind.is_nominal() && !tok.kind.is_adjective(),
+ );
Self {
pattern: Box::new(pattern),
diff --git a/harper-core/src/linting/pronoun_contraction/should_contract.rs b/harper-core/src/linting/pronoun_contraction/should_contract.rs
index af480636d..4e876364e 100644
--- a/harper-core/src/linting/pronoun_contraction/should_contract.rs
+++ b/harper-core/src/linting/pronoun_contraction/should_contract.rs
@@ -19,7 +19,7 @@ impl Default for ShouldContract {
.then_whitespace()
.t_aco("the")
.then_whitespace()
- .then_noun(),
+ .then_nominal(),
),
}
}
diff --git a/harper-core/src/linting/proper_noun_capitalization_linters.rs b/harper-core/src/linting/proper_nominal_capitalization_linters.rs
similarity index 96%
rename from harper-core/src/linting/proper_noun_capitalization_linters.rs
rename to harper-core/src/linting/proper_nominal_capitalization_linters.rs
index d58ff9c88..703577a61 100644
--- a/harper-core/src/linting/proper_noun_capitalization_linters.rs
+++ b/harper-core/src/linting/proper_nominal_capitalization_linters.rs
@@ -5,13 +5,13 @@ use crate::{Dictionary, make_title_case};
use crate::{Token, TokenStringExt};
use std::sync::Arc;
-pub struct ProperNounCapitalizationLinter<D: Dictionary + 'static> {
+pub struct ProperNominalCapitalizationLinter<D: Dictionary + 'static> {
pattern: Box<dyn Pattern>,
description: String,
dictionary: Arc<D>,
}
-impl<D: Dictionary + 'static> ProperNounCapitalizationLinter<D> {
+impl<D: Dictionary + 'static> ProperNominalCapitalizationLinter<D> {
pub fn new(
search_for: impl Pattern + 'static,
description: impl ToString,
@@ -30,7 +30,7 @@ impl<D: Dictionary + 'static> ProperNounCapitalizationLinter<D> {
}
}
-impl<D: Dictionary + 'static> PatternLinter for ProperNounCapitalizationLinter<D> {
+impl<D: Dictionary + 'static> PatternLinter for ProperNominalCapitalizationLinter<D> {
fn pattern(&self) -> &dyn Pattern {
self.pattern.as_ref()
}
@@ -57,7 +57,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"Americas",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
SequencePattern::default()
.then(WordSet::new(&["South", "North", "Central"]))
.then_whitespace()
@@ -68,7 +68,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"Australia",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
EitherPattern::new(vec![
// the states and territories
Box::new(
@@ -132,7 +132,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"OceansAndSeas",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
EitherPattern::new(vec![
Box::new(
SequencePattern::default()
@@ -178,7 +178,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"Canada",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
EitherPattern::new(vec![
// the provinces and territories
Box::new(
@@ -228,7 +228,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"Koreas",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
SequencePattern::default()
.then(WordSet::new(&["South", "North"]))
.then_whitespace()
@@ -240,7 +240,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"Malaysia",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
EitherPattern::new(vec![
// multi-word states
Box::new(SequencePattern::default()
@@ -296,7 +296,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"ChineseCommunistParty",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
SequencePattern::aco("Chinese")
.then_whitespace()
.t_aco("Communist")
@@ -309,7 +309,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"UnitedOrganizations",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
SequencePattern::default()
.t_aco("United")
.then_whitespace()
@@ -331,7 +331,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"Holidays",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
EitherPattern::new(vec![
Box::new(
SequencePattern::default()
@@ -481,7 +481,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"AmazonNames",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
SequencePattern::default()
.t_aco("Amazon")
.then_whitespace()
@@ -551,7 +551,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"GoogleNames",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
SequencePattern::default()
.t_aco("Google")
.then_whitespace()
@@ -586,7 +586,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"AzureNames",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
SequencePattern::default()
.t_aco("Azure")
.then_whitespace()
@@ -663,7 +663,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"MicrosoftNames",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
SequencePattern::default()
.t_aco("Microsoft")
.then_whitespace()
@@ -697,7 +697,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"AppleNames",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
SequencePattern::default()
.t_aco("Apple")
.then_whitespace()
@@ -743,7 +743,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"MetaNames",
- Box::new(ProperNounCapitalizationLinter::new(SequencePattern::aco("Meta")
+ Box::new(ProperNominalCapitalizationLinter::new(SequencePattern::aco("Meta")
.then_whitespace()
.then(EitherPattern::new(vec![
Box::new(WordSet::new(&[
@@ -763,7 +763,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"JetpackNames",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
SequencePattern::default()
.t_aco("Jetpack")
.then_whitespace()
@@ -814,7 +814,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"TumblrNames",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
SequencePattern::default()
.t_aco("Tumblr")
.then_whitespace()
@@ -834,7 +834,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"PocketCastsNames",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
EitherPattern::new(vec![
Box::new(
SequencePattern::default()
@@ -858,7 +858,7 @@ pub fn lint_group(dictionary: Arc<impl Dictionary + 'static>) -> LintGroup {
group.add(
"DayOneNames",
- Box::new(ProperNounCapitalizationLinter::new(
+ Box::new(ProperNominalCapitalizationLinter::new(
EitherPattern::new(vec![
Box::new(
SequencePattern::default()
diff --git a/harper-core/src/linting/sentence_capitalization.rs b/harper-core/src/linting/sentence_capitalization.rs
index 4fe9abe15..650d7255e 100644
--- a/harper-core/src/linting/sentence_capitalization.rs
+++ b/harper-core/src/linting/sentence_capitalization.rs
@@ -67,13 +67,13 @@ impl Linter for SentenceCapitalization {
}
fn is_full_sentence(toks: &[Token]) -> bool {
- let mut has_noun = false;
+ let mut has_nominal = false;
let mut has_verb = false;
for tok in toks {
if let TokenKind::Word(Some(metadata)) = tok.kind {
- if metadata.is_noun() {
- has_noun = true;
+ if metadata.is_nominal() {
+ has_nominal = true;
}
if metadata.is_verb() {
@@ -82,7 +82,7 @@ fn is_full_sentence(toks: &[Token]) -> bool {
}
}
- has_noun && has_verb
+ has_nominal && has_verb
}
#[cfg(test)]
diff --git a/harper-core/src/linting/use_genitive.rs b/harper-core/src/linting/use_genitive.rs
index 83be96161..2bf88beb6 100644
--- a/harper-core/src/linting/use_genitive.rs
+++ b/harper-core/src/linting/use_genitive.rs
@@ -16,9 +16,9 @@ impl UseGenitive {
SequencePattern::default()
.then_one_or_more_adjectives()
.then_whitespace()
- .then_noun(),
+ .then_nominal(),
),
- Box::new(SequencePattern::default().then_noun()),
+ Box::new(SequencePattern::default().then_nominal()),
]),
));
@@ -86,7 +86,7 @@ mod tests {
use super::UseGenitive;
#[test]
- fn catches_adjective_noun() {
+ fn catches_adjective_nominal() {
assert_suggestion_result(
"What are there big problems?",
UseGenitive::default(),
@@ -95,7 +95,7 @@ mod tests {
}
#[test]
- fn catches_just_noun() {
+ fn catches_just_nominal() {
assert_suggestion_result(
"What are there problems?",
UseGenitive::default(),
diff --git a/harper-core/src/patterns/mod.rs b/harper-core/src/patterns/mod.rs
index 738397930..7354e81c1 100644
--- a/harper-core/src/patterns/mod.rs
+++ b/harper-core/src/patterns/mod.rs
@@ -20,7 +20,7 @@ mod indefinite_article;
mod invert;
mod is_not_title_case;
mod naive_pattern_group;
-mod noun_phrase;
+mod nominal_phrase;
mod repeating_pattern;
mod sequence_pattern;
mod similar_to_phrase;
@@ -44,7 +44,7 @@ pub use indefinite_article::IndefiniteArticle;
pub use invert::Invert;
pub use is_not_title_case::IsNotTitleCase;
pub use naive_pattern_group::NaivePatternGroup;
-pub use noun_phrase::NounPhrase;
+pub use nominal_phrase::NominalPhrase;
pub use repeating_pattern::RepeatingPattern;
pub use sequence_pattern::SequencePattern;
pub use similar_to_phrase::SimilarToPhrase;
diff --git a/harper-core/src/patterns/noun_phrase.rs b/harper-core/src/patterns/nominal_phrase.rs
similarity index 80%
rename from harper-core/src/patterns/noun_phrase.rs
rename to harper-core/src/patterns/nominal_phrase.rs
index 4a69959c5..827b07d83 100644
--- a/harper-core/src/patterns/noun_phrase.rs
+++ b/harper-core/src/patterns/nominal_phrase.rs
@@ -3,9 +3,9 @@ use crate::Token;
use super::Pattern;
#[derive(Default)]
-pub struct NounPhrase;
+pub struct NominalPhrase;
-impl Pattern for NounPhrase {
+impl Pattern for NominalPhrase {
fn matches(&self, tokens: &[Token], _source: &[char]) -> usize {
let mut cursor = 0;
@@ -27,7 +27,7 @@ impl Pattern for NounPhrase {
continue;
}
- if tok.kind.is_noun() {
+ if tok.kind.is_nominal() {
return cursor + 1;
}
@@ -39,13 +39,13 @@ impl Pattern for NounPhrase {
#[cfg(test)]
mod tests {
use super::super::DocPattern;
- use super::NounPhrase;
+ use super::NominalPhrase;
use crate::{Document, Span, patterns::Pattern};
#[test]
fn simple_apple() {
let doc = Document::new_markdown_default_curated("A red apple");
- let matches = NounPhrase.find_all_matches_in_doc(&doc);
+ let matches = NominalPhrase.find_all_matches_in_doc(&doc);
assert_eq!(matches, vec![Span::new(0, 5)])
}
@@ -53,7 +53,7 @@ mod tests {
#[test]
fn complex_apple() {
let doc = Document::new_markdown_default_curated("A red apple with a long stem");
- let matches = NounPhrase.find_all_matches_in_doc(&doc);
+ let matches = NominalPhrase.find_all_matches_in_doc(&doc);
assert_eq!(matches, vec![Span::new(0, 5), Span::new(8, 13)])
}
@@ -61,7 +61,7 @@ mod tests {
#[test]
fn list_fruit() {
let doc = Document::new_markdown_default_curated("An apple, a banana and a pear");
- let matches = NounPhrase.find_all_matches_in_doc(&doc);
+ let matches = NominalPhrase.find_all_matches_in_doc(&doc);
assert_eq!(
matches,
@@ -72,7 +72,7 @@ mod tests {
#[test]
fn simplest_banana() {
let doc = Document::new_markdown_default_curated("a banana");
- assert!(NounPhrase.matches(doc.get_tokens(), doc.get_source()) != 0);
+ assert!(NominalPhrase.matches(doc.get_tokens(), doc.get_source()) != 0);
}
#[test]
@@ -80,7 +80,7 @@ mod tests {
let doc = Document::new_markdown_default_curated(
"My favorite foods are pizza, sushi, tacos and burgers.",
);
- let matches = NounPhrase.find_all_matches_in_doc(&doc);
+ let matches = NominalPhrase.find_all_matches_in_doc(&doc);
dbg!(&matches);
diff --git a/harper-core/src/patterns/sequence_pattern.rs b/harper-core/src/patterns/sequence_pattern.rs
index 19983967e..5910efb67 100644
--- a/harper-core/src/patterns/sequence_pattern.rs
+++ b/harper-core/src/patterns/sequence_pattern.rs
@@ -21,7 +21,7 @@ use crate::{Token, TokenKind};
///
/// let document = Document::new_markdown_default_curated("This is a test.");
///
-/// let pattern = SequencePattern::default().then_article().then_whitespace().then_noun();
+/// let pattern = SequencePattern::default().then_article().then_whitespace().then_nominal();
/// let matches = pattern.find_all_matches_in_doc(&document);
///
/// // The pattern found that the tokens at indexes 4, 5, and 6 fit the criteria.
@@ -66,9 +66,9 @@ macro_rules! gen_then_from_is {
}
impl SequencePattern {
- gen_then_from_is!(noun);
- gen_then_from_is!(possessive_noun);
- gen_then_from_is!(plural_noun);
+ gen_then_from_is!(nominal);
+ gen_then_from_is!(possessive_nominal);
+ gen_then_from_is!(plural_nominal);
gen_then_from_is!(verb);
gen_then_from_is!(linking_verb);
gen_then_from_is!(pronoun);
@@ -83,7 +83,7 @@ impl SequencePattern {
gen_then_from_is!(apostrophe);
gen_then_from_is!(hyphen);
gen_then_from_is!(article);
- gen_then_from_is!(proper_noun);
+ gen_then_from_is!(proper_nominal);
pub fn then_indefinite_article(self) -> Self {
self.then(IndefiniteArticle::default())
diff --git a/harper-core/src/patterns/singular_subject.rs b/harper-core/src/patterns/singular_subject.rs
index 4adfe1faa..b0c4b3c31 100644
--- a/harper-core/src/patterns/singular_subject.rs
+++ b/harper-core/src/patterns/singular_subject.rs
@@ -11,7 +11,7 @@ impl Default for SingularSubject {
Self {
inner: SequencePattern::default()
.then_pronoun()
- .or(Box::new(SequencePattern::default().then_proper_noun())),
+ .or(Box::new(SequencePattern::default().then_proper_nominal())),
}
}
}
diff --git a/harper-core/src/spell/hunspell/mod.rs b/harper-core/src/spell/hunspell/mod.rs
index 886548dbf..819b0aa16 100644
--- a/harper-core/src/spell/hunspell/mod.rs
+++ b/harper-core/src/spell/hunspell/mod.rs
@@ -131,12 +131,12 @@ mod tests {
}
],
"adds_metadata": {
- "noun": {
+ "nominal": {
"is_plural": true
}
},
"gifts_metadata": {
- "noun": {}
+ "nominal": {}
}
},
"M": {
@@ -162,10 +162,10 @@ mod tests {
attributes.expand_marked_words(words, &mut expanded);
let giant_data = expanded.get(&split("giant")).unwrap();
- assert!(giant_data.is_noun());
+ assert!(giant_data.is_nominal());
let giants_data = expanded.get(&split("giants")).unwrap();
- assert!(giants_data.is_plural_noun());
+ assert!(giants_data.is_plural_nominal());
}
fn build_expanded() -> HashMap<CharString, WordMetadata> {
@@ -209,18 +209,18 @@ mod tests {
build_expanded()
.get(&split("abandonment's"))
.unwrap()
- .is_possessive_noun()
+ .is_possessive_nominal()
)
}
#[test]
- fn has_is_not_a_noun() {
+ fn has_is_not_a_nominal() {
let expanded = build_expanded();
let has = expanded.get(&split("has"));
assert!(has.is_some());
- assert!(!has.unwrap().is_noun(),)
+ assert!(!has.unwrap().is_nominal(),)
}
#[test]
diff --git a/harper-core/src/spell/mod.rs b/harper-core/src/spell/mod.rs
index 6e0b53d72..e057bf2dc 100644
--- a/harper-core/src/spell/mod.rs
+++ b/harper-core/src/spell/mod.rs
@@ -59,12 +59,12 @@ fn order_suggestions(matches: Vec<FuzzyMatchResult>) -> Vec<&[char]> {
found.swap(0, 2);
}
- if let Some(noun_index) = found
+ if let Some(nominal_index) = found
.iter()
.skip(3)
- .position(|i| i.metadata.is_proper_noun())
+ .position(|i| i.metadata.is_proper_nominal())
{
- found.swap(2, noun_index + 3);
+ found.swap(2, nominal_index + 3);
}
// Make commonality relevant
diff --git a/harper-core/src/spell/mutable_dictionary.rs b/harper-core/src/spell/mutable_dictionary.rs
index 71c88dac3..f96ba607f 100644
--- a/harper-core/src/spell/mutable_dictionary.rs
+++ b/harper-core/src/spell/mutable_dictionary.rs
@@ -328,10 +328,10 @@ mod tests {
}
#[test]
- fn this_is_noun() {
+ fn this_is_nominal() {
let dict = MutableDictionary::curated();
- assert!(dict.get_word_metadata_str("this").unwrap().is_noun());
- assert!(dict.get_word_metadata_str("This").unwrap().is_noun());
+ assert!(dict.get_word_metadata_str("this").unwrap().is_nominal());
+ assert!(dict.get_word_metadata_str("This").unwrap().is_nominal());
}
#[test]
@@ -347,12 +347,12 @@ mod tests {
assert!(
dict.get_word_metadata_str("herself")
.unwrap()
- .is_pronoun_noun()
+ .is_pronoun_nominal()
);
assert!(
dict.get_word_metadata_str("Herself")
.unwrap()
- .is_pronoun_noun()
+ .is_pronoun_nominal()
);
}
@@ -386,12 +386,12 @@ mod tests {
fn there_is_not_a_pronoun() {
let dict = MutableDictionary::curated();
- assert!(!dict.get_word_metadata_str("there").unwrap().is_noun());
+ assert!(!dict.get_word_metadata_str("there").unwrap().is_nominal());
assert!(
!dict
.get_word_metadata_str("there")
.unwrap()
- .is_pronoun_noun()
+ .is_pronoun_nominal()
);
}
}
diff --git a/harper-core/src/title_case.rs b/harper-core/src/title_case.rs
index e6876cf89..9acf1e478 100644
--- a/harper-core/src/title_case.rs
+++ b/harper-core/src/title_case.rs
@@ -36,7 +36,7 @@ pub fn make_title_case(toks: &[Token], source: &[char], dict: &impl Dictionary)
while let Some((index, word)) = word_likes.next() {
if let Some(Some(metadata)) = word.kind.as_word() {
- if metadata.is_proper_noun() {
+ if metadata.is_proper_nominal() {
// Replace it with the dictionary entry verbatim.
let orig_text = word.span.get_content(source);
diff --git a/harper-core/src/token_kind.rs b/harper-core/src/token_kind.rs
index bb0fa508e..83bfdddfd 100644
--- a/harper-core/src/token_kind.rs
+++ b/harper-core/src/token_kind.rs
@@ -1,7 +1,7 @@
use is_macro::Is;
use serde::{Deserialize, Serialize};
-use crate::{ConjunctionData, NounData, Number, Punctuation, Quote, WordMetadata};
+use crate::{ConjunctionData, NominalData, Number, Punctuation, Quote, WordMetadata};
#[derive(
Debug, Is, Clone, Copy, Serialize, Deserialize, Default, PartialOrd, Hash, Eq, PartialEq,
@@ -51,11 +51,11 @@ impl TokenKind {
)
}
- pub fn is_possessive_noun(&self) -> bool {
+ pub fn is_possessive_nominal(&self) -> bool {
matches!(
self,
TokenKind::Word(Some(WordMetadata {
- noun: Some(NounData {
+ nominal: Some(NominalData {
is_possessive: Some(true),
..
}),
@@ -68,7 +68,7 @@ impl TokenKind {
matches!(
self,
TokenKind::Word(Some(WordMetadata {
- noun: Some(NounData {
+ nominal: Some(NominalData {
is_pronoun: Some(true),
..
}),
@@ -77,11 +77,11 @@ impl TokenKind {
)
}
- pub fn is_proper_noun(&self) -> bool {
+ pub fn is_proper_nominal(&self) -> bool {
matches!(
self,
TokenKind::Word(Some(WordMetadata {
- noun: Some(NounData {
+ nominal: Some(NominalData {
is_proper: Some(true),
..
}),
@@ -255,20 +255,20 @@ impl TokenKind {
metadata.is_linking_verb()
}
- pub fn is_not_pronoun_noun(&self) -> bool {
+ pub fn is_not_pronoun_nominal(&self) -> bool {
let TokenKind::Word(Some(metadata)) = self else {
return true;
};
- metadata.is_not_pronoun_noun()
+ metadata.is_not_pronoun_nominal()
}
- pub fn is_not_plural_noun(&self) -> bool {
+ pub fn is_not_plural_nominal(&self) -> bool {
let TokenKind::Word(Some(metadata)) = self else {
return true;
};
- metadata.is_not_plural_noun()
+ metadata.is_not_plural_nominal()
}
pub fn is_common_word(&self) -> bool {
@@ -279,20 +279,20 @@ impl TokenKind {
metadata.common
}
- pub fn is_plural_noun(&self) -> bool {
+ pub fn is_plural_nominal(&self) -> bool {
let TokenKind::Word(Some(metadata)) = self else {
return false;
};
- metadata.is_plural_noun()
+ metadata.is_plural_nominal()
}
- pub fn is_noun(&self) -> bool {
+ pub fn is_nominal(&self) -> bool {
let TokenKind::Word(Some(metadata)) = self else {
return false;
};
- metadata.is_noun()
+ metadata.is_nominal()
}
pub fn is_likely_homograph(&self) -> bool {
diff --git a/harper-core/src/word_metadata.rs b/harper-core/src/word_metadata.rs
index caa64ee5d..f1330780c 100644
--- a/harper-core/src/word_metadata.rs
+++ b/harper-core/src/word_metadata.rs
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Hash)]
pub struct WordMetadata {
- pub noun: Option<NounData>,
+ pub nominal: Option<NominalData>,
pub verb: Option<VerbData>,
pub adjective: Option<AdjectiveData>,
pub adverb: Option<AdverbData>,
@@ -89,7 +89,7 @@ impl WordMetadata {
}
Self {
- noun: merge!(self.noun, other.noun),
+ nominal: merge!(self.nominal, other.nominal),
verb: merge!(self.verb, other.verb),
adjective: merge!(self.adjective, other.adjective),
adverb: merge!(self.adverb, other.adverb),
@@ -102,7 +102,7 @@ impl WordMetadata {
}
generate_metadata_queries!(
- noun has proper, plural, possessive, pronoun.
+ nominal has proper, plural, possessive, pronoun.
verb has linking.
conjunction has.
adjective has.
@@ -145,14 +145,14 @@ impl VerbData {
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq, Hash, Default)]
-pub struct NounData {
+pub struct NominalData {
pub is_proper: Option<bool>,
pub is_plural: Option<bool>,
pub is_possessive: Option<bool>,
pub is_pronoun: Option<bool>,
}
-impl NounData {
+impl NominalData {
/// Produce a copy of `self` with the known properties of `other` set.
pub fn or(&self, other: &Self) -> Self {
Self {
diff --git a/harper-core/tests/run_tests.rs b/harper-core/tests/run_tests.rs
index 78819757c..6d30e126a 100644
--- a/harper-core/tests/run_tests.rs
+++ b/harper-core/tests/run_tests.rs
@@ -40,7 +40,7 @@ create_test!(issue_109_ext.md, 0);
create_test!(chinese_lorem_ipsum.md, 2);
create_test!(obsidian_links.md, 2);
create_test!(issue_267.md, 0);
-create_test!(proper_noun_capitalization.md, 2);
+create_test!(proper_nominal_capitalization.md, 2);
create_test!(amazon_hostname.md, 0);
create_test!(issue_159.md, 1);
create_test!(issue_358.md, 0);
diff --git a/harper-core/tests/test_sources/proper_noun_capitalization.md b/harper-core/tests/test_sources/proper_nominal_capitalization.md
similarity index 100%
rename from harper-core/tests/test_sources/proper_noun_capitalization.md
rename to harper-core/tests/test_sources/proper_nominal_capitalization.md
diff --git a/harper-typst/src/lib.rs b/harper-typst/src/lib.rs
index bd9ed1bbf..c0d7bbf42 100644
--- a/harper-typst/src/lib.rs
+++ b/harper-typst/src/lib.rs
@@ -39,7 +39,7 @@ mod tests {
use ordered_float::OrderedFloat;
use super::Typst;
- use harper_core::{Document, NounData, Number, Punctuation, TokenKind, WordMetadata};
+ use harper_core::{Document, NominalData, Number, Punctuation, TokenKind, WordMetadata};
#[test]
fn number() {
@@ -298,7 +298,7 @@ mod tests {
token_kinds.as_slice(),
&[
TokenKind::Word(Some(WordMetadata {
- noun: Some(NounData {
+ nominal: Some(NominalData {
is_possessive: Some(true),
..
}),
diff --git a/packages/web/src/routes/docs/contributors/author-a-rule/+page.md b/packages/web/src/routes/docs/contributors/author-a-rule/+page.md
index 843fdb4d9..64eb11b86 100644
--- a/packages/web/src/routes/docs/contributors/author-a-rule/+page.md
+++ b/packages/web/src/routes/docs/contributors/author-a-rule/+page.md
@@ -53,7 +53,7 @@ All you have to do is add a line to `harper-core/src/linting/phrase_corrections.
This method also covers more complex cases, like if one of the words contains capitalization or the phrase is split by a line break.
-Similarly, if you just want Harper to enforce proper capitalization of a multi-token proper noun (like "Tumblr Blaze") you just need to add an entry to `harper-core/src/linting/proper_noun_capitalization_linters.rs`.
+Similarly, if you just want Harper to enforce proper capitalization of a multi-token proper noun (like "Tumblr Blaze") you just need to add an entry to `harper-core/src/linting/proper_nominal_capitalization_linters.rs`.
```rust
group.add(