Referencepluralize

<pluralize>

Renders a word in its singular or plural form based on a count

<pluralize> is a Text component that renders its content in singular or plural form. By default it pluralizes a single noun; when the content is a count-and-noun pair ("3 dog", "one mouse") it inspects the count and pluralizes only if the count is not 11.

<pluralize> extends <text>, so it can be referenced and displayed anywhere a text value is accepted. Pluralization uses the compromise NLP library and handles common English irregulars (mouse → mice, goose → geese, pony → ponies).

Attributes and Properties

Attributes for <pluralize>

Positioning (2)
anchor

point. Default value: \(\left( 0, 0 \right)\). Coordinates of the anchor point used to position this component on a graph.

positionFromAnchor

keyword. Where this component sits relative to its anchor point.

ValueDescription
upperRightPlace the component above and to the right of the anchor point.
upperLeftPlace the component above and to the left of the anchor point.
lowerRightPlace the component below and to the right of the anchor point.
lowerLeftPlace the component below and to the left of the anchor point.
topPlace the component directly above the anchor point.
bottomPlace the component directly below the anchor point.
leftPlace the component directly to the left of the anchor point.
rightPlace the component directly to the right of the anchor point.
center (default)Center the component on the anchor point.
Other (5)

number. Number that determines whether to use the singular or plural form.

draggable

boolean. Default value: true. Whether the text can be dragged on a graph.

isLatex

boolean. Default value: false. Whether the text content is treated as LaTeX.

layer

number. Default value: 0. Z-order layer index when shown on a graph.

text. Custom plural form to use (overrides automatic pluralization).

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <pluralize name="p">

Positioning (2)
$p.anchor

point. The coordinates where this component is anchored on the graph.

$p.positionFromAnchor

text. Where this component sits relative to its anchor point.

Other (22)
$p.backgroundColor

text. Human-readable name for this component's background color, derived from the active style and theme.

$p.basedOnNumber

number. Number that determines whether to use the singular or plural form.

$p.characters

[ text ]. The text value split into characters (graphemes).

$p.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$p.draggable

boolean. Whether the text can be dragged on a graph.

$p.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$p.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$p.hidden

boolean. Whether this component is hidden from the rendered output.

$p.isLatex

boolean. Whether the text content is treated as LaTeX.

$p.layer

number. Z-order layer index when shown on a graph.

$p.list

[ text ]. The text value split into items at commas.

$p.math

math. The text parsed as a math expression.

$p.number

number. The text parsed as a number.

$p.numCharacters

integer. The number of characters (graphemes) in the text value.

$p.numListItems

integer. The number of comma-separated items when the text is interpreted as a list.

$p.numWords

integer. The number of words in the text value.

$p.pluralForm

text. Custom plural form to use (overrides automatic pluralization).

$p.text

text. The selected word as a text string.

$p.textColor

text. Human-readable name for this component's text color, derived from the active style and theme.

$p.textStyleDescription

text. Human-readable description of this component's text styling (color and any background color).

$p.value

text. The selected (singular or plural) word.

$p.words

[ text ]. The text value split into words.

Common to all components (4)
$p.doenetML

text. The DoenetML source code that produced this component.

$p.hide

boolean. Whether to hide this component from the rendered output.

$p.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$p.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: Default behaviour

A bare noun is converted to its plural form using standard English pluralization rules, including common irregulars.


Example: Pluralize based on a leading count

When the content begins with a count (numeric or written), the noun is pluralized only when the count is not 11. So 1 dog stays as 1 dog, 2 dog becomes 2 dogs, and 0 dog becomes 0 dogs.

Attribute Examples

Attribute Example: basedOnNumber

basedOnNumber takes a number reference and pluralizes the content based on its value rather than on any count parsed out of the content text. Useful when the count lives in a separate component (a <mathInput>, a property of another component, etc.).


Attribute Example: pluralForm

pluralForm overrides the auto-detected plural. The content’s noun is replaced verbatim with the pluralForm string when the count designates a plural; the singular form is used otherwise.