Function Repository Resource:

WordPrefix

Source Notebook

Separate an English word from its prefix if one is present

Contributed by: Mark Greenberg

ResourceFunction["WordPrefix"][wd]

returns wd divided into its prefix, if there is one, and the rest of the word.

Details and Options

The argument wd must be a string.
The rules for identifying prefixes are based on common English words in WordList.
To split off multiple prefixes from one word, nest ResourceFunction["WordPrefix"].
ResourceFunction["WordPrefix"] has the attribute Listable.

Examples

Basic Examples (1) 

Separate a word from its first prefix:

In[1]:=
ResourceFunction["WordPrefix"]["misconstrued"]
Out[1]=

Scope (2) 

Separate a word from multiple prefixes:

In[2]:=
Flatten[Nest[ResourceFunction["WordPrefix"][#] &, "misconstrued", 2]]
Out[2]=

Separate prefixes in a list of words:

In[3]:=
ResourceFunction["WordPrefix"] /@ RandomWord[10]
Out[3]=

Possible Issues (1) 

Whether part of a word is a prefix or a root is sometimes a judgment call. WordPrefix attempts to make sensible judgments in those cases:

In[4]:=
ResourceFunction["WordPrefix"][{"unilateral", "unities"}]
Out[4]=

Publisher

Mark Greenberg

Version History

  • 1.0.0 – 14 August 2019

License Information