Orthography
in package
Utility functions for checking the orthography of arbitrary text strings.
An orthography is a set of conventions for writing a language. It includes norms of spelling, hyphenation, capitalization, word breaks, emphasis, and punctuation. Source: https://en.wikipedia.org/wiki/Orthography
Tags
Table of Contents
Constants
- TERMINAL_POINTS = '.?!'
- Characters which are considered terminal points for a sentence.
Methods
- isFirstCharCapitalized() : bool
- Check if the first character of an arbitrary text string is a capital letter.
- isFirstCharLowercase() : bool
- Check if the first character of an arbitrary text string is a lowercase letter.
- isLastCharPunctuation() : bool
- Check if the last character of an arbitrary text string is a valid punctuation character.
Constants
TERMINAL_POINTS
Characters which are considered terminal points for a sentence.
public
string
TERMINAL_POINTS
= '.?!'
Tags
Methods
isFirstCharCapitalized()
Check if the first character of an arbitrary text string is a capital letter.
public
static isFirstCharCapitalized(string $textString) : bool
Letter characters which do not have a concept of lower/uppercase will be accepted as correctly capitalized.
Parameters
- $textString : string
-
The text string to examine. This can be the contents of a text string token, but also, for instance, a comment text. Potential text delimiter quotes should be stripped off a text string before passing it to this method. Also see: TextStrings::stripQuotes().
Tags
Return values
bool —TRUE
when the first character is a capital letter or a letter
which doesn't have a concept of capitalization.
FALSE
otherwise, including for non-letter characters.
isFirstCharLowercase()
Check if the first character of an arbitrary text string is a lowercase letter.
public
static isFirstCharLowercase(string $textString) : bool
Parameters
- $textString : string
-
The text string to examine. This can be the contents of a text string token, but also, for instance, a comment text. Potential text delimiter quotes should be stripped off a text string before passing it to this method. Also see: TextStrings::stripQuotes().
Tags
Return values
bool —TRUE
when the first character is a lowercase letter.
FALSE
otherwise, including for letters which don't have a concept of
capitalization and for non-letter characters.
isLastCharPunctuation()
Check if the last character of an arbitrary text string is a valid punctuation character.
public
static isLastCharPunctuation(string $textString[, string $allowedChars = self::TERMINAL_POINTS ]) : bool
Parameters
- $textString : string
-
The text string to examine. This can be the contents of a text string token, but also, for instance, a comment text. Potential text delimiter quotes should be stripped off a text string before passing it to this method. Also see: TextStrings::stripQuotes().
- $allowedChars : string = self::TERMINAL_POINTS
-
Characters which are considered valid punctuation to end the text string. Defaults to
'.?!'
, i.e. a full stop, question mark or exclamation mark.