Skip to main content

dale_chall/
lib.rs

1//! List of easy American-English words: New Dale-Chall (1995).
2//!
3//! This crate ships one thing: the New Dale-Chall familiar-word list as a
4//! sorted, deduplicated, lowercase slice of string literals. Readability tools
5//! use the list to decide whether a word is familiar when scoring text. The
6//! crate does not compute the Dale-Chall formula. It only provides the data.
7//!
8//! The list holds 2942 entries. Every entry is lowercase ASCII. Most are plain
9//! letters. Nine words contain a hyphen and 47 contain a straight apostrophe
10//! (`'`, U+0027). The slice is sorted ascending by byte order, which for this
11//! all-ASCII data matches Unicode code-point order. A caller can check
12//! membership with `DALE_CHALL.binary_search(&word).is_ok()`.
13//!
14//! Membership is exact and case sensitive. The data is already lowercase. The
15//! crate does not fold case or trim input. Callers normalize query words before
16//! a lookup.
17//!
18//! The crate is `#![no_std]`. The data lives in `core`, so embedded and kernel
19//! callers can use it.
20//!
21//! # Examples
22//!
23//! ```
24//! use dale_chall::DALE_CHALL;
25//!
26//! assert_eq!(DALE_CHALL.len(), 2942);
27//! assert_eq!(DALE_CHALL[0], "a");
28//! assert!(DALE_CHALL.binary_search(&"old-fashioned").is_ok());
29//! assert!(DALE_CHALL.binary_search(&"xylophone").is_err());
30//! ```
31
32#![no_std]
33#![forbid(unsafe_code)]
34#![warn(missing_docs)]
35
36mod words;
37
38/// List of easy American-English words: New Dale-Chall (1995).
39///
40/// A sorted, deduplicated, lowercase slice of 2942 familiar words. The order is
41/// ascending byte order, which equals Unicode code-point order here because
42/// every entry is ASCII. The slice is `'static` and immutable.
43///
44/// The slice is sorted, so `binary_search` finds a word in `O(log n)`.
45///
46/// # Examples
47///
48/// ```
49/// use dale_chall::DALE_CHALL;
50///
51/// assert_eq!(DALE_CHALL.first(), Some(&"a"));
52/// assert_eq!(DALE_CHALL.last(), Some(&"youth"));
53/// assert!(DALE_CHALL.binary_search(&"don't").is_ok());
54/// assert!(DALE_CHALL.binary_search(&"Ache").is_err());
55/// ```
56pub const DALE_CHALL: &[&str] = words::WORDS;