<pluralize>
<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
.
<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)
anchorpoint. Default value: . Coordinates of the anchor point used to position this component on a graph.
positionFromAnchorkeyword. Where this component sits relative to its anchor point.
| Value | Description |
|---|---|
upperRight | Place the component above and to the right of the anchor point. |
upperLeft | Place the component above and to the left of the anchor point. |
lowerRight | Place the component below and to the right of the anchor point. |
lowerLeft | Place the component below and to the left of the anchor point. |
top | Place the component directly above the anchor point. |
bottom | Place the component directly below the anchor point. |
left | Place the component directly to the left of the anchor point. |
right | Place 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.
draggableboolean. Default value: true. Whether the text can be dragged on a graph.
isLatexboolean. Default value: false. Whether the text content is treated as LaTeX.
layernumber. 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)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. 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.anchorpoint. The coordinates where this component is anchored on the graph.
$p.positionFromAnchortext. Where this component sits relative to its anchor point.
Other (22)
$p.backgroundColortext. Human-readable name for this component's background color, derived from the active style and theme.
$p.basedOnNumbernumber. Number that determines whether to use the singular or plural form.
$p.characters[ text ]. The text value split into characters (graphemes).
$p.disabledboolean. Whether this component is disabled and cannot be interacted with.
$p.draggableboolean. Whether the text can be dragged on a graph.
$p.fixedboolean. Whether this component's value is fixed and cannot be modified.
$p.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$p.isLatexboolean. Whether the text content is treated as LaTeX.
$p.layernumber. Z-order layer index when shown on a graph.
$p.list[ text ]. The text value split into items at commas.
$p.mathmath. The text parsed as a math expression.
$p.numbernumber. The text parsed as a number.
$p.numCharactersinteger. The number of characters (graphemes) in the text value.
$p.numListItemsinteger. The number of comma-separated items when the text is interpreted as a list.
$p.numWordsinteger. The number of words in the text value.
$p.pluralFormtext. Custom plural form to use (overrides automatic pluralization).
$p.texttext. The selected word as a text string.
$p.textColortext. Human-readable name for this component's text color, derived from the active style and theme.
$p.textStyleDescriptiontext. Human-readable description of this component's text styling (color and any background color).
$p.valuetext. The selected (singular or plural) word.
$p.words[ text ]. The text value split into words.
Common to all components (4)
$p.doenetMLtext. The DoenetML source code that produced this component.
$p.hideboolean. Whether to hide this component from the rendered output.
$p.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$p.styleNumberinteger. 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 . 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.