repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-comments/src/comment_parsers/mod.rs | harper-comments/src/comment_parsers/mod.rs | mod go;
mod javadoc;
mod jsdoc;
mod lua;
mod solidity;
mod unit;
pub use go::Go;
use harper_core::Span;
pub use javadoc::JavaDoc;
pub use jsdoc::JsDoc;
pub use lua::Lua;
pub use solidity::Solidity;
pub use unit::Unit;
/// Get the span of a tree-sitter-produced comment that doesn't include the
/// comment openers and ... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-comments/src/comment_parsers/lua.rs | harper-comments/src/comment_parsers/lua.rs | use harper_core::Lrc;
use harper_core::Span;
use harper_core::Token;
use harper_core::parsers::{Markdown, MarkdownOptions, Parser};
use super::without_initiators;
#[derive(Clone)]
pub struct Lua {
inner: Lrc<dyn Parser>,
}
impl Lua {
pub fn new(parser: Lrc<dyn Parser>) -> Self {
Self { inner: parser ... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-comments/src/comment_parsers/javadoc.rs | harper-comments/src/comment_parsers/javadoc.rs | use std::collections::VecDeque;
use harper_core::parsers::Parser;
use harper_core::{Punctuation, Token, TokenKind, VecExt};
use harper_html::HtmlParser;
use super::without_initiators;
#[derive(Default)]
pub struct JavaDoc {
html_parser: HtmlParser,
}
impl Parser for JavaDoc {
fn parse(&self, source: &[char]... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-comments/tests/language_support.rs | harper-comments/tests/language_support.rs | use std::path::Path;
use harper_comments::CommentParser;
use harper_core::linting::{LintGroup, Linter};
use harper_core::parsers::MarkdownOptions;
use harper_core::spell::FstDictionary;
use harper_core::{Dialect, Document};
/// Creates a unit test checking that the linting of a source file in
/// `language_support_so... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-comments/tests/language_support_sources/ignore_comments.rs | harper-comments/tests/language_support_sources/ignore_comments.rs | /// spellcheck:ignore splling error
/// This applies to the entire comment block
#[derive(Debug)]
/// Ths comment block is checked
pub struct Testing {
// spellchecker: ignore ths struct isnt done yt
}
| rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-comments/tests/language_support_sources/eof.rs | harper-comments/tests/language_support_sources/eof.rs | fn main() {}
// This is a test to ensure Harper doesn't crash on comments at the end of files.
| rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-comments/tests/language_support_sources/issue_132.rs | harper-comments/tests/language_support_sources/issue_132.rs | /// ```
/// println!("Test");
/// ```
///
/// This shoud get checked.
fn main() {
println!("Hello, world!");
}
| rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-comments/tests/language_support_sources/clean.rs | harper-comments/tests/language_support_sources/clean.rs | /// This is an example Rust file that should produce no Harper lints.
struct TestStruct {}
impl TestStruct {
/// This is a test function.
/// It has a [link](https://example.com) embedded inside
fn test_function() {}
/// This is another test function.
/// It has another [link](https://example.com... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-cli/src/annotate_tokens.rs | harper-cli/src/annotate_tokens.rs | use ariadne::{Color, Label};
use clap::ValueEnum;
use harper_core::{Document, Span, Token, TokenKind};
use strum::IntoEnumIterator;
/// Represents an annotation.
pub(super) struct Annotation {
/// The range the annotation covers in the source. For instance, this might be a single word.
span: Span<char>,
//... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-cli/src/lint.rs | harper-cli/src/lint.rs | use std::collections::BTreeMap;
use std::path::{Component, Path, PathBuf};
use std::sync::Arc;
use std::{fs, process};
use ariadne::{Color, Fmt, Label, Report, ReportKind, Source};
use hashbrown::HashMap;
use rayon::prelude::*;
use harper_core::{
linting::{Lint, LintGroup, LintGroupConfig, LintKind},
parsers:... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-cli/src/main.rs | harper-cli/src/main.rs | #![doc = include_str!("../README.md")]
use harper_core::spell::{Dictionary, FstDictionary, MutableDictionary, WordId};
use hashbrown::HashMap;
use std::collections::BTreeMap;
use std::fs::File;
use std::io::BufReader;
use std::path::{Path, PathBuf};
// use std::sync::Arc;
use std::fs;
use anyhow::anyhow;
use ariadne:... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | true |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-cli/src/input.rs | harper-cli/src/input.rs | use std::{borrow::Cow, io::Read, path::PathBuf};
use harper_core::spell::Dictionary;
use harper_core::{
Document,
parsers::{MarkdownOptions, PlainEnglish},
};
/// Represents an input/source passed via the command line. For example, this can be a file, or
/// text passed via the command line directly.
#[derive... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/dict_word_metadata_orthography.rs | harper-core/src/dict_word_metadata_orthography.rs | use crate::CharStringExt;
use crate::char_ext::CharExt;
use serde::{Deserialize, Serialize};
/// Orthography information.
pub enum Orthography {
/// Every char that is a letter is lowercase.
Lowercase = 1 << 0,
/// First char is uppercase, the rest is lowercase (but multi-word?)
Titlecase = 1 << 1,
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/punctuation.rs | harper-core/src/punctuation.rs | use is_macro::Is;
use serde::{Deserialize, Serialize};
use crate::Currency;
#[derive(
Debug, Is, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Default, Hash,
)]
#[serde(tag = "kind")]
pub enum Punctuation {
/// `°`
Degree,
/// `…`
Ellipsis,
/// `–`
EnDash,
/// `—`
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/lib.rs | harper-core/src/lib.rs | #![doc = include_str!("../README.md")]
#![allow(dead_code)]
mod char_ext;
mod char_string;
mod currency;
mod dict_word_metadata;
mod dict_word_metadata_orthography;
mod document;
mod edit_distance;
pub mod expr;
mod fat_token;
mod ignored_lints;
mod irregular_nouns;
mod irregular_verbs;
pub mod language_detection;
mod... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/number.rs | harper-core/src/number.rs | use std::fmt::Display;
use is_macro::Is;
use ordered_float::OrderedFloat;
use serde::{Deserialize, Serialize};
/// Represents a written number.
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd)]
pub struct Number {
/// The actual value of the number
pub value: Orde... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/char_string.rs | harper-core/src/char_string.rs | use crate::char_ext::CharExt;
use std::borrow::Cow;
use smallvec::SmallVec;
/// A char sequence that improves cache locality.
/// Most English words are fewer than 12 characters.
pub type CharString = SmallVec<[char; 16]>;
mod private {
pub trait Sealed {}
impl Sealed for [char] {}
}
/// Extensions to char... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/document.rs | harper-core/src/document.rs | use std::cmp::Ordering;
use std::collections::VecDeque;
use std::fmt::Display;
use harper_brill::{Chunker, Tagger, brill_tagger, burn_chunker};
use itertools::Itertools;
use paste::paste;
use crate::expr::{Expr, ExprExt, FirstMatchOf, Repeating, SequenceExpr};
use crate::parsers::{Markdown, MarkdownOptions, Parser, P... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | true |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/sync.rs | harper-core/src/sync.rs | #[cfg(not(feature = "concurrent"))]
pub use std::rc::Rc as Lrc;
#[cfg(feature = "concurrent")]
pub use std::sync::Arc as Lrc;
#[cfg(not(feature = "concurrent"))]
pub trait LSend {}
#[cfg(not(feature = "concurrent"))]
impl<T: ?Sized> LSend for T {}
#[cfg(feature = "concurrent")]
pub trait LSend: Send + Sync {}
#[cfg... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/char_ext.rs | harper-core/src/char_ext.rs | use unicode_script::{Script, UnicodeScript};
use unicode_width::UnicodeWidthChar;
use crate::Punctuation;
mod private {
pub trait Sealed {}
impl Sealed for char {}
}
pub trait CharExt: private::Sealed {
fn is_cjk(&self) -> bool;
/// Whether a character can be a component of an English word.
fn i... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/render_markdown.rs | harper-core/src/render_markdown.rs | use ammonia::clean;
use pulldown_cmark::{Options, Parser, html};
/// The standard Markdown rendering function for the crate.
/// Do not call `pulldown_cmark` directly. Use this.
pub fn render_markdown(markdown: &str) -> String {
let parser = Parser::new_ext(markdown, Options::all());
let mut html = String::new... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/dict_word_metadata.rs | harper-core/src/dict_word_metadata.rs | use harper_brill::UPOS;
use is_macro::Is;
use itertools::Itertools;
use paste::paste;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use strum::{EnumCount as _, VariantArray as _};
use strum_macros::{Display, EnumCount, EnumIter, EnumString, VariantArray};
use std::convert::TryFrom;
use crate::dict_word... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | true |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/token_kind.rs | harper-core/src/token_kind.rs | use harper_brill::UPOS;
use is_macro::Is;
use serde::{Deserialize, Serialize};
use crate::{DictWordMetadata, Number, Punctuation, Quote, TokenKind::Word};
/// Generate wrapper code to pass a function call to the inner [`DictWordMetadata`],
/// if the token is indeed a word, while also emitting method-level document... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/vec_ext.rs | harper-core/src/vec_ext.rs | use std::collections::VecDeque;
mod private {
pub trait Sealed {}
impl<T> Sealed for Vec<T> {}
}
/// Extensions on top of [`Vec`] that make certain common operations easier.
pub trait VecExt: private::Sealed {
/// Removes a list of indices from a Vector.
/// Assumes that the provided indices are alre... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/language_detection.rs | harper-core/src/language_detection.rs | //! This module implements rudimentary, dictionary-based English language detection.
use crate::spell::Dictionary;
use crate::{Document, Token, TokenKind};
/// Check if the contents of the document are likely intended to represent
/// English.
pub fn is_doc_likely_english(doc: &Document, dict: &impl Dictionary) -> bo... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/fat_token.rs | harper-core/src/fat_token.rs | use serde::{Deserialize, Serialize};
use crate::{CharStringExt, TokenKind};
/// A [`Token`](crate::Token) that holds its content as a fat [`Vec<char>`] rather than as a
/// [`Span`](crate::Span).
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, PartialOrd, Hash, Eq)]
pub struct FatToken {
pub content: Ve... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/span.rs | harper-core/src/span.rs | use std::{fmt::Display, marker::PhantomData, ops::Range};
use serde::{Deserialize, Serialize};
use crate::Token;
/// A window in a [`T`] sequence.
///
/// Note that the range covered by a [`Span`] is end-exclusive, meaning that the end index is not
/// included in the range covered by the [`Span`]. If you're familia... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/irregular_verbs.rs | harper-core/src/irregular_verbs.rs | use lazy_static::lazy_static;
use serde::Deserialize;
use std::sync::Arc;
type Verb = (String, String, String);
#[derive(Debug, Deserialize)]
pub struct IrregularVerbs {
verbs: Vec<Verb>,
}
/// The uncached function that is used to produce the original copy of the
/// irregular verb table.
fn uncached_inner_new(... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/currency.rs | harper-core/src/currency.rs | use is_macro::Is;
use serde::{Deserialize, Serialize};
use crate::Number;
/// A national or international currency
#[derive(Debug, Is, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Hash)]
pub enum Currency {
// $
Dollar,
// ¢
Cent,
// €
Euro,
// ₽
Ruble,
// ₺
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/irregular_nouns.rs | harper-core/src/irregular_nouns.rs | use lazy_static::lazy_static;
use serde::Deserialize;
use std::sync::Arc;
type Noun = (String, String);
#[derive(Debug, Deserialize)]
pub struct IrregularNouns {
nouns: Vec<Noun>,
}
/// The uncached function that is used to produce the original copy of the
/// irregular noun table.
fn uncached_inner_new() -> Arc... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/token_string_ext.rs | harper-core/src/token_string_ext.rs | use crate::{Span, Token};
use itertools::Itertools;
use paste::paste;
macro_rules! create_decl_for {
($thing:ident) => {
paste! {
fn [< first_ $thing >](&self) -> Option<&Token>;
fn [< last_ $thing >](&self) -> Option<&Token>;
fn [< last_ $thing _index >](&self) -> Opt... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/edit_distance.rs | harper-core/src/edit_distance.rs | // Computes the Levenshtein edit distance between two patterns.
// This is accomplished via a memory-optimized Wagner-Fischer algorithm
//
// This variant avoids allocation if you already have buffers.
#[inline]
pub fn edit_distance_min_alloc(
source: &[char],
target: &[char],
previous_row: &mut Vec<u8>,
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/title_case.rs | harper-core/src/title_case.rs | use std::borrow::Cow;
use crate::Lrc;
use crate::Token;
use crate::TokenKind;
use hashbrown::HashSet;
use lazy_static::lazy_static;
use crate::Punctuation;
use crate::spell::Dictionary;
use crate::{CharStringExt, Document, TokenStringExt, parsers::Parser};
/// A helper function for [`make_title_case`] that uses Stri... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/token.rs | harper-core/src/token.rs | use serde::{Deserialize, Serialize};
use crate::{FatToken, Span, TokenKind};
/// Represents a semantic, parsed component of a [`Document`](crate::Document).
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub struct Token {
/// The characters the token represents.
pub span: Span<char>,
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/lexing/hostname.rs | harper-core/src/lexing/hostname.rs | use crate::TokenKind;
use super::FoundToken;
/// Lex a hostname token.
pub fn lex_hostname_token(source: &[char]) -> Option<FoundToken> {
let len = lex_hostname(source)?;
// Might be word, just skip it.
if len <= 1 {
return None;
}
if !source.get(1..len - 1)?.contains(&'.') {
ret... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/lexing/url.rs | harper-core/src/lexing/url.rs | /// This module implements parsing of URIs.
/// See RFC 1738 for more information.
use super::{FoundToken, hostname::lex_hostname};
use crate::TokenKind;
pub fn lex_url(source: &[char]) -> Option<FoundToken> {
let sep = source.iter().position(|c| *c == ':')?;
if !validate_scheme(&source[0..sep]) {
ret... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/lexing/email_address.rs | harper-core/src/lexing/email_address.rs | use itertools::Itertools;
use super::FoundToken;
use super::hostname::lex_hostname;
use crate::TokenKind;
pub fn lex_email_address(source: &[char]) -> Option<FoundToken> {
// Location of the @ sign
let (at_loc, _) = source.iter().enumerate().rev().find(|(_, c)| **c == '@')?;
let local_part = &source[0..a... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/lexing/mod.rs | harper-core/src/lexing/mod.rs | mod email_address;
mod hostname;
mod url;
use hostname::lex_hostname_token;
use ordered_float::OrderedFloat;
use url::lex_url;
use self::email_address::lex_email_address;
use crate::char_ext::CharExt;
use crate::punctuation::{Punctuation, Quote};
use crate::{Number, TokenKind};
#[derive(Debug, Eq, PartialEq)]
pub st... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/repeating.rs | harper-core/src/expr/repeating.rs | use super::Expr;
use crate::{Span, Token};
/// An expression that will match one or more repetitions of the same expression.
///
/// Somewhat reminiscent of the `+*` operator in Regex.
pub struct Repeating {
inner: Box<dyn Expr>,
required_repetitions: usize,
}
impl Repeating {
pub fn new(expr: Box<dyn Exp... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/mergeable_words.rs | harper-core/src/expr/mergeable_words.rs | use std::sync::Arc;
use super::{Expr, SequenceExpr, SpaceOrHyphen};
use crate::spell::{Dictionary, FstDictionary};
use crate::{CharString, DictWordMetadata, Span, Token};
type PredicateFn =
dyn Fn(Option<&DictWordMetadata>, Option<&DictWordMetadata>) -> bool + Send + Sync;
/// An [`Expr`] that identifies adjacen... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/optional.rs | harper-core/src/expr/optional.rs | use crate::{Span, Token};
use super::Expr;
/// An optional expression.
/// Forces the optional expression to always return Some by transmuting `None` into
/// `Some(cursor..cursor)`.
pub struct Optional {
inner: Box<dyn Expr>,
}
impl Optional {
pub fn new(inner: impl Expr + 'static) -> Self {
Self {
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/all.rs | harper-core/src/expr/all.rs | use crate::{Span, Token, expr::Expr};
/// An [`Expr`] that matches against tokens if and only if all of its children do.
/// This can be useful for situations where you have multiple expressions that represent a grammatical
/// error, but you need _all_ of them to match to be certain.
///
/// It will return the positi... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/duration_expr.rs | harper-core/src/expr/duration_expr.rs | use crate::patterns::{IndefiniteArticle, WordSet};
use crate::{Span, Token};
use super::{Expr, SequenceExpr, SpelledNumberExpr};
#[derive(Default)]
pub struct DurationExpr;
impl Expr for DurationExpr {
fn run(&self, cursor: usize, tokens: &[Token], source: &[char]) -> Option<Span<Token>> {
if tokens.is_e... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/anchor_start.rs | harper-core/src/expr/anchor_start.rs | use crate::{Token, TokenStringExt};
use super::Step;
/// A [`Step`] which will match only if the cursor is over the first word-like of a token stream.
/// It will return that token.
pub struct AnchorStart;
impl Step for AnchorStart {
fn step(&self, tokens: &[Token], cursor: usize, _source: &[char]) -> Option<isi... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/spelled_number_expr.rs | harper-core/src/expr/spelled_number_expr.rs | use crate::expr::LongestMatchOf;
use crate::patterns::{WhitespacePattern, WordSet};
use crate::{Span, Token};
use super::{Expr, SequenceExpr};
/// Matches spelled-out numbers from one to ninety-nine
#[derive(Default)]
pub struct SpelledNumberExpr;
impl Expr for SpelledNumberExpr {
fn run(&self, cursor: usize, to... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/anchor_end.rs | harper-core/src/expr/anchor_end.rs | use crate::Token;
use super::Step;
/// A [`Step`] which will match only if the cursor is over the last non-whitespace character in stream.
/// It will return that token.
///
/// For example, if you built `SequenceExpr::default().t_aco("word").then(AnchorEnd)` and ran it on `This is a word`, the resulting `Span` would... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/word_expr_group.rs | harper-core/src/expr/word_expr_group.rs | use hashbrown::HashMap;
use super::first_match_of::FirstMatchOf;
use super::{Expr, SequenceExpr};
use crate::{CharString, Span, Token};
/// An expression collection to look for expressions that start with a specific
/// word.
///
/// The benefit of using this struct over other methods increases for larger collections... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/longest_match_of.rs | harper-core/src/expr/longest_match_of.rs | use crate::{Span, Token, expr::Expr};
/// An [`Expr`] that returns the farthest offset of the longest match in a list of expressions.
#[derive(Default)]
pub struct LongestMatchOf {
exprs: Vec<Box<dyn Expr>>,
}
impl LongestMatchOf {
pub fn new(exprs: Vec<Box<dyn Expr>>) -> Self {
Self { exprs }
}
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/step.rs | harper-core/src/expr/step.rs | use crate::{LSend, Token, patterns::Pattern};
/// An atomic step within a larger expression.
///
/// Its principle job is to identify (if any) the next position of the cursor.
/// When cursor is moved, all tokens between the current cursor and the target position will be
/// added to the match group.
pub trait Step: L... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/space_or_hyphen.rs | harper-core/src/expr/space_or_hyphen.rs | use crate::expr::FirstMatchOf;
use crate::patterns::WhitespacePattern;
use crate::{Span, Token};
use super::Expr;
/// Matches either a space or a hyphen, useful for matching compound words.
#[derive(Default)]
pub struct SpaceOrHyphen;
impl Expr for SpaceOrHyphen {
fn run(&self, cursor: usize, tokens: &[Token], s... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/similar_to_phrase.rs | harper-core/src/expr/similar_to_phrase.rs | use crate::patterns::{WithinEditDistance, Word};
use crate::{Document, Span, Token, TokenKind};
use super::{Expr, SequenceExpr};
pub struct SimilarToPhrase {
phrase: SequenceExpr,
fuzzy_phrase: SequenceExpr,
}
impl SimilarToPhrase {
/// Create an error-tolerant SequenceExpr that looks for phrases similar... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/mod.rs | harper-core/src/expr/mod.rs | //! An `Expr` is a declarative way to express whether a certain set of tokens fulfill a criteria.
//!
//! For example, if we want to look for the word "that" followed by an adjective, we could build an
//! expression to do so.
//!
//! The actual searching is done by another system (usually a part of the [lint framework... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/fixed_phrase.rs | harper-core/src/expr/fixed_phrase.rs | use crate::patterns::Word;
use crate::{Document, Span, Token, TokenKind};
use super::{Expr, SequenceExpr};
/// Matches a fixed sequence of tokens as they appear in the input.
/// Case-insensitive for words but maintains exact matching for other token types.
///
/// # Example
///
/// ```rust
/// use harper_core::expr:... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/reflexive_pronoun.rs | harper-core/src/expr/reflexive_pronoun.rs | use crate::{
Span, Token,
expr::{Expr, FirstMatchOf},
patterns::WordSet,
};
// These are considered ungrammatical, or are at least not in `dictionary.dict` but are commonly used anyway.
// The tests below check if this changes so we can update this `Expr`
const BAD_REFLEXIVE_PRONOUNS: &[&str] = &[
"his... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/sequence_expr.rs | harper-core/src/expr/sequence_expr.rs | use paste::paste;
use crate::{
CharStringExt, Span, Token, TokenKind,
expr::{FirstMatchOf, FixedPhrase, LongestMatchOf},
patterns::{AnyPattern, IndefiniteArticle, WhitespacePattern, Word, WordSet},
};
use super::{Expr, Optional, OwnedExprExt, Repeating, Step, UnlessStep};
#[derive(Default)]
pub struct Se... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/time_unit_expr.rs | harper-core/src/expr/time_unit_expr.rs | use crate::expr::LongestMatchOf;
use crate::patterns::WordSet;
use crate::{Span, Token};
use super::Expr;
/// Matches a time unit.
///
/// Matches standard units from microsecond to decade.
/// Matches other 'units' such as moment, night, weekend.
/// Matches singular and plural forms.
/// Matches possessive forms (w... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/unless_step.rs | harper-core/src/expr/unless_step.rs | use crate::{Token, expr::Expr};
use super::Step;
/// Provides the ability to use an expression as a condition.
/// If the condition does __not match__, it will return the result of the provided step.
pub struct UnlessStep<E: Expr, S: Step> {
condition: E,
step: S,
}
impl<E, S> UnlessStep<E, S>
where
E: E... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/first_match_of.rs | harper-core/src/expr/first_match_of.rs | use super::Expr;
use crate::{Span, Token};
/// A naive expr collection that naively iterates through a list of patterns,
/// returning the first one that matches.
///
/// Compare to [`LongestMatchOf`](super::LongestMatchOf), which returns the longest match.
#[derive(Default)]
pub struct FirstMatchOf {
exprs: Vec<B... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/expr/expr_map.rs | harper-core/src/expr/expr_map.rs | use crate::LSend;
use crate::Span;
use crate::Token;
use super::Expr;
/// A map from an [`Expr`] to arbitrary data.
///
/// It has been a common pattern for rule authors to build a list of expressions that match a
/// grammatical error.
/// Then, depending on which expression was matched, a suggestion is chosen from ... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/mask/mod.rs | harper-core/src/mask/mod.rs | use itertools::Itertools;
use crate::Span;
/// A Masker is a tool that can be composed to eliminate chunks of text from
/// being parsed. They can be composed to do things like isolate comments from a
/// programming language or disable linting for languages that have been
/// determined to not be English.
///
/// Th... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/ignored_lints/lint_context.rs | harper-core/src/ignored_lints/lint_context.rs | use std::hash::{DefaultHasher, Hash, Hasher};
use serde::{Deserialize, Serialize};
use crate::{
Document, FatToken,
linting::{Lint, LintKind, Suggestion},
};
/// A location-agnostic structure that attempts to captures the context and content that a [`Lint`]
/// occurred.
#[derive(Debug, Hash, Serialize, Dese... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/ignored_lints/mod.rs | harper-core/src/ignored_lints/mod.rs | mod lint_context;
use hashbrown::HashSet;
pub use lint_context::LintContext;
use serde::{Deserialize, Serialize};
use crate::{Document, linting::Lint};
/// A structure that keeps track of lints that have been ignored by users.
///
/// To use this structure, apply [`Self::remove_ignored`] on the output of a
/// [`Lin... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/implies_quantity.rs | harper-core/src/patterns/implies_quantity.rs | use crate::{Token, TokenKind};
use super::SingleTokenPattern;
/// This struct does two things.
///
/// First, it acts as a pattern that looks for phrases that describe a quantity of a noun
/// that may or may not succeed it.
///
/// Second, it determines the implied plurality of that quantity.implies
pub struct Impli... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/modal_verb.rs | harper-core/src/patterns/modal_verb.rs | use super::{Pattern, WordSet};
pub struct ModalVerb {
inner: WordSet,
include_common_errors: bool,
}
impl Default for ModalVerb {
fn default() -> Self {
let (words, include_common_errors) = Self::init(false);
Self {
inner: words,
include_common_errors,
}
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/word_set.rs | harper-core/src/patterns/word_set.rs | use super::SingleTokenPattern;
use smallvec::SmallVec;
use crate::{CharString, Token};
/// A [`super::Pattern`] that matches against any of a set of provided words.
/// For small sets of short words, it doesn't allocate.
///
/// Note that any capitalization of the contained words will result in a match.
#[derive(Debu... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/inflection_of_be.rs | harper-core/src/patterns/inflection_of_be.rs | use super::SingleTokenPattern;
use crate::Token;
use crate::patterns::WordSet;
/// Matches any inflection of the verb “be”:
/// `am`, `is`, `are`, `was`, `were`, `be`, `been`, `being`.
pub struct InflectionOfBe {
/// If using a `WordSet` proves expensive, we'll switch to something else.
inner: WordSet,
}
impl... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/upos_set.rs | harper-core/src/patterns/upos_set.rs | use harper_brill::UPOS;
use serde::{Deserialize, Serialize};
use smallvec::{SmallVec, ToSmallVec};
use crate::Token;
use super::Pattern;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UPOSSet {
allowed_tags: SmallVec<[UPOS; 10]>,
}
impl UPOSSet {
pub fn new(allowed: &[UPOS]) -> Self {
Se... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/invert.rs | harper-core/src/patterns/invert.rs | use crate::Token;
use super::Pattern;
/// A struct that matches any pattern __except__ the one provided.
pub struct Invert {
inner: Box<dyn Pattern>,
}
impl Invert {
pub fn new(inner: impl Pattern + 'static) -> Self {
Self {
inner: Box::new(inner),
}
}
}
impl Pattern for Inve... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/indefinite_article.rs | harper-core/src/patterns/indefinite_article.rs | use crate::Token;
use super::{SingleTokenPattern, WordSet};
pub struct IndefiniteArticle {
inner: WordSet,
}
impl Default for IndefiniteArticle {
fn default() -> Self {
Self {
inner: WordSet::new(&["a", "an"]),
}
}
}
impl SingleTokenPattern for IndefiniteArticle {
fn matc... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/whitespace_pattern.rs | harper-core/src/patterns/whitespace_pattern.rs | use super::Pattern;
pub struct WhitespacePattern;
impl Pattern for WhitespacePattern {
fn matches(&self, tokens: &[crate::Token], _source: &[char]) -> Option<usize> {
let count = tokens
.iter()
.position(|t| !t.kind.is_whitespace())
.unwrap_or(tokens.len());
if... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/within_edit_distance.rs | harper-core/src/patterns/within_edit_distance.rs | use std::cell::RefCell;
use super::SingleTokenPattern;
use crate::{CharString, CharStringExt, Token};
use crate::edit_distance::edit_distance_min_alloc;
/// Matches single words within a certain edit distance of a given word.
pub struct WithinEditDistance {
word: CharString,
max_edit_dist: u8,
}
impl Within... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/mod.rs | harper-core/src/patterns/mod.rs | //! [`Pattern`]s are one of the more powerful ways to query text inside Harper, especially for beginners. They are a simplified abstraction over [`Expr`](crate::expr::Expr).
//!
//! Through the [`ExprLinter`](crate::linting::ExprLinter) trait, they make it much easier to
//! build Harper [rules](crate::linting::Linter)... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/derived_from.rs | harper-core/src/patterns/derived_from.rs | use crate::spell::WordId;
use super::Pattern;
/// A [Pattern] that looks for Word tokens that are either derived from a given word, or the word
/// itself.
///
/// For example, this will match "call" as well as "recall", "calling", etc.
pub struct DerivedFrom {
word_id: WordId,
}
impl DerivedFrom {
pub fn ne... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/word.rs | harper-core/src/patterns/word.rs | use super::SingleTokenPattern;
use crate::{CharString, Token};
/// Matches a predefined word.
#[derive(Clone)]
pub struct Word {
/// The word to match.
word: CharString,
/// Determines whether the match is case-sensitive.
case_sensitive: bool,
}
impl Word {
/// Matches the provided word, ignoring... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/any_pattern.rs | harper-core/src/patterns/any_pattern.rs | use crate::Token;
use super::SingleTokenPattern;
/// Matches any single token.
pub struct AnyPattern;
impl SingleTokenPattern for AnyPattern {
fn matches_token(&self, _token: &Token, _source: &[char]) -> bool {
true
}
}
| rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/prepositional_preceder.rs | harper-core/src/patterns/prepositional_preceder.rs | use lazy_static::lazy_static;
use super::{SingleTokenPattern, WordSet};
use crate::Token;
/// Matches adjectives that routinely introduce a `… to …` prepositional phrase, such as
/// `accustomed`, `prone`, or `used`.
///
/// Several `ToTwoToo` branches need this guard so they only flag cases where `to` is meant as
//... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/patterns/nominal_phrase.rs | harper-core/src/patterns/nominal_phrase.rs | use crate::Token;
use super::Pattern;
/// A pattern that uses primitive syntax-tree heuristics to locate nominal phrases.
/// Given that it does not take context into account, it is not recommended for new code.
/// Please prefer [`DictWordMetadata::np_member`](crate::DictWordMetadata::np_member).
#[derive(Default)]
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/merged_dictionary.rs | harper-core/src/spell/merged_dictionary.rs | use std::borrow::Cow;
use std::hash::{BuildHasher, Hasher};
use std::sync::Arc;
use foldhash::quality::FixedState;
use itertools::Itertools;
use super::{FstDictionary, WordId};
use super::{FuzzyMatchResult, dictionary::Dictionary};
use crate::{CharString, DictWordMetadata};
/// A simple wrapper over [`Dictionary`] t... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/word_id.rs | harper-core/src/spell/word_id.rs | use std::hash::BuildHasher;
use foldhash::fast::FixedState;
use serde::{Deserialize, Serialize};
use crate::{CharString, CharStringExt};
/// An identifier for a particular word.
///
/// It works by hashing the word it represents, normalized to lowercase.
/// It is meant for situations where you need to refer to a wo... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/trie_dictionary.rs | harper-core/src/spell/trie_dictionary.rs | use lazy_static::lazy_static;
use std::borrow::Cow;
use std::sync::Arc;
use trie_rs::Trie;
use trie_rs::iter::{Keys, PrefixIter, SearchIter};
use crate::DictWordMetadata;
use super::{Dictionary, FstDictionary, FuzzyMatchResult, WordId};
/// A [`Dictionary`] optimized for pre- and postfix search.
/// Wraps another d... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/word_map.rs | harper-core/src/spell/word_map.rs | use hashbrown::{HashMap, hash_map::IntoValues};
use crate::{CharString, DictWordMetadata};
use super::WordId;
/// The underlying data structure for the `MutableDictionary`.
#[derive(Debug, Clone, Eq, PartialEq, Default)]
pub struct WordMap {
inner: HashMap<WordId, WordMapEntry>,
}
#[derive(Debug, Clone, Eq, Par... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/fst_dictionary.rs | harper-core/src/spell/fst_dictionary.rs | use super::{MutableDictionary, WordId};
use fst::{IntoStreamer, Map as FstMap, Streamer, map::StreamWithState};
use hashbrown::HashMap;
use lazy_static::lazy_static;
use levenshtein_automata::{DFA, LevenshteinAutomatonBuilder};
use std::borrow::Cow;
use std::{cell::RefCell, sync::Arc};
use crate::{CharString, CharStri... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/dictionary.rs | harper-core/src/spell/dictionary.rs | use blanket::blanket;
use std::borrow::Cow;
use super::FuzzyMatchResult;
use super::WordId;
use crate::DictWordMetadata;
/// An in-memory database that contains everything necessary to parse and analyze English text.
///
/// See also: [`super::FstDictionary`] and [`super::MutableDictionary`].
#[blanket(derive(Arc))]
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/mod.rs | harper-core/src/spell/mod.rs | //! Contains the relevant code for performing dictionary lookups and spellchecking (i.e. fuzzy
//! dictionary lookups).
use itertools::Itertools;
use crate::{CharString, CharStringExt, DictWordMetadata};
pub use self::dictionary::Dictionary;
pub use self::fst_dictionary::FstDictionary;
pub use self::merged_dictionar... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/mutable_dictionary.rs | harper-core/src/spell/mutable_dictionary.rs | use super::{
FstDictionary, WordId,
rune::{self, AttributeList, parse_word_list},
word_map::{WordMap, WordMapEntry},
};
use crate::edit_distance::edit_distance_min_alloc;
use itertools::Itertools;
use lazy_static::lazy_static;
use std::borrow::Cow;
use std::sync::Arc;
use crate::{CharString, CharStringExt,... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/rune/expansion.rs | harper-core/src/spell/rune/expansion.rs | use serde::{Deserialize, Serialize};
use super::Error;
use super::affix_replacement::{AffixReplacement, HumanReadableAffixReplacement};
use crate::DictWordMetadata;
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum AffixEntryKind {
Suffix,
Prefix,
}
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/rune/error.rs | harper-core/src/spell/rune/error.rs | use super::matcher;
use serde_json::Error as SerdeJsonError;
#[derive(Debug, Clone, thiserror::Error)]
pub enum Error {
#[error("The provided file's item count was malformed.")]
MalformedItemCount,
#[error("Expected affix flag to be exactly one character.")]
MultiCharacterFlag,
#[error("Expected a... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/rune/attribute_list.rs | harper-core/src/spell/rune/attribute_list.rs | use hashbrown::HashMap;
use serde::{Deserialize, Serialize};
use smallvec::ToSmallVec;
use super::super::word_map::{WordMap, WordMapEntry};
use super::Error;
use super::affix_replacement::AffixReplacement;
use super::expansion::Property;
use super::expansion::{
AffixEntryKind,
AffixEntryKind::{Prefix, Suffix},... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/rune/mod.rs | harper-core/src/spell/rune/mod.rs | mod affix_replacement;
mod attribute_list;
mod error;
mod expansion;
mod matcher;
pub mod word_list;
pub use attribute_list::AttributeList;
pub use error::Error;
pub use self::word_list::parse_word_list;
#[cfg(test)]
mod tests {
use hashbrown::HashSet;
use once_cell::sync::Lazy;
use serde_json::json;
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/rune/matcher.rs | harper-core/src/spell/rune/matcher.rs | use std::fmt::{Display, Formatter};
use serde::{Deserialize, Serialize};
/// A simplified, Regex-like matcher.
///
/// See the Hunspell documentation on affixes for more information.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Matcher {
/// Position-based operators.
operators: Vec<Operator>,
}
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/rune/affix_replacement.rs | harper-core/src/spell/rune/affix_replacement.rs | use serde::{Deserialize, Serialize};
use super::Error;
use super::matcher::Matcher;
#[derive(Debug, Clone)]
pub struct AffixReplacement {
pub remove: Vec<char>,
pub add: Vec<char>,
pub condition: Matcher,
}
impl AffixReplacement {
pub fn to_human_readable(&self) -> HumanReadableAffixReplacement {
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/spell/rune/word_list.rs | harper-core/src/spell/rune/word_list.rs | use super::Error;
use crate::CharString;
#[derive(Debug, Clone)]
pub struct AnnotatedWord {
pub letters: CharString,
pub annotations: Vec<char>,
}
/// Parse a Rune word list
///
/// Returns [`None`] if the given string is invalid.
pub fn parse_word_list(source: &str) -> Result<Vec<AnnotatedWord>, Error> {
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/linting/far_be_it.rs | harper-core/src/linting/far_be_it.rs | use crate::char_string::CharStringExt;
use crate::expr::{Expr, SequenceExpr};
use crate::linting::expr_linter::Chunk;
use crate::linting::{ExprLinter, Lint, LintKind, Suggestion};
use crate::token::Token;
pub struct FarBeIt {
expr: Box<dyn Expr>,
}
impl Default for FarBeIt {
fn default() -> Self {
Sel... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/linting/handful.rs | harper-core/src/linting/handful.rs | use crate::expr::{Expr, SequenceExpr, SpaceOrHyphen};
use crate::linting::expr_linter::Chunk;
use crate::{Token, TokenStringExt};
use super::{ExprLinter, Lint, LintKind, Suggestion};
pub struct Handful {
expr: Box<dyn Expr>,
}
impl Default for Handful {
fn default() -> Self {
let expr = SequenceExpr:... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/linting/modal_seem.rs | harper-core/src/linting/modal_seem.rs | use std::sync::Arc;
use crate::linting::expr_linter::Chunk;
use crate::{
CharStringExt, Token,
expr::{Expr, ExprMap, SequenceExpr},
linting::{ExprLinter, Lint, LintKind, Suggestion},
patterns::ModalVerb,
};
#[derive(Clone, Copy, Default)]
struct MatchContext {
modal_index: usize,
}
pub struct Mod... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/linting/single_be.rs | harper-core/src/linting/single_be.rs | use crate::dict_word_metadata::VerbFormFlags;
use crate::linting::expr_linter::Chunk;
use crate::{
Span, Token,
expr::{Expr, SequenceExpr},
linting::{ExprLinter, Lint, LintKind, Suggestion},
patterns::{DerivedFrom, InflectionOfBe},
};
fn be_forms(token: &Token) -> Option<VerbFormFlags> {
let metada... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/linting/since_duration.rs | harper-core/src/linting/since_duration.rs | use crate::expr::{DurationExpr, Expr, SequenceExpr};
use crate::{CharStringExt, Token, TokenStringExt};
use super::{ExprLinter, Lint, LintKind, Suggestion};
use crate::linting::expr_linter::Chunk;
const AGO_VARIANTS: [&[char]; 3] = [&['a', 'g', 'o'], &['A', 'g', 'o'], &['A', 'G', 'O']];
const FOR_VARIANTS: [&[char]; ... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/linting/am_in_the_morning.rs | harper-core/src/linting/am_in_the_morning.rs | use crate::linting::expr_linter::Chunk;
use crate::{
Span, Token, TokenStringExt,
expr::{Expr, FixedPhrase, LongestMatchOf, SequenceExpr},
linting::{ExprLinter, Lint, LintKind, Suggestion},
patterns::WordSet,
};
pub struct AmInTheMorning {
expr: Box<dyn Expr>,
}
impl Default for AmInTheMorning {
... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/linting/pronoun_knew.rs | harper-core/src/linting/pronoun_knew.rs | use harper_brill::UPOS;
use crate::expr::Expr;
use crate::expr::LongestMatchOf;
use crate::expr::SequenceExpr;
use crate::linting::expr_linter::Chunk;
use crate::{
Token,
linting::{ExprLinter, Lint, LintKind, Suggestion},
patterns::WordSet,
};
pub struct PronounKnew {
expr: Box<dyn Expr>,
}
trait Pro... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Automattic/harper | https://github.com/Automattic/harper/blob/51e02866aea0eade6a0581792c76cfa2c289cb84/harper-core/src/linting/regionalisms.rs | harper-core/src/linting/regionalisms.rs | use crate::{
Dialect::{self, American, Australian, British, Canadian, Indian},
Token, TokenStringExt,
expr::{Expr, FirstMatchOf, FixedPhrase},
linting::{Lint, LintKind, Suggestion},
};
use super::ExprLinter;
use crate::linting::expr_linter::Chunk;
#[derive(PartialEq)]
enum CanFlag {
/// Flag this ... | rust | Apache-2.0 | 51e02866aea0eade6a0581792c76cfa2c289cb84 | 2026-01-04T15:46:30.661431Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.