How to make a function that decides whether a word starts with a vowel?

vowel = [a e i o u];
starts = vowel==1;
function [string] = vowel(input)
if starts == 1
print 'this word starts with a vowel'
end

 Accepted Answer

function y=vowel(input)
if regexp(input,'\<[aeiou | AEIOU]')==1
fprintf('This word starts with a vowel\n');
y=true;
else
fprintf('This word does not start with a vowel\n');
y=false;
end
end

2 Comments

This regular expression is misleading, because the vertical bar implies an OR operation, whereas in fact this

[aeiou | AEIOU]

actually matches any character that is contained in the square brackets, including space and the vertical bar, which have no special meaning inside square brackets (unless used as part of a range, which they are not here). They are rendered superfluous by the \< operator. So this could be simply:

[aeiouAEIOU]

or even using regexpi simply:

[aeiou]

Sign in to comment.

More Answers (1)

Deciding whether a word starts with a vowel is a bit easier in English than deciding in any other position of a word, as there are some vowels that can never occur in the first character of an English word.
But unfortunately the task is still not easy. Checking for a e i o or u is quite easy, but deciding whether a leading "y" is a vowel or a consonant is a bit tricky. If the leading y is followed by a consonant then chances go up that the y is a vowel. For example ytterbium begins with a vowel. In some words borrowed from German or some of the Slavic languages, a leading j can be a vowel even if it is followed by another vowel, such as German origin jagerschnitzel, where the j is the vowel form of y. There are deep historical connections between y and j so at first pass you should assume that any special treatment for y might need to be replicated for j, even if only for a smaller number of words.

2 Comments

As a native speaker of German, I do not think „Jägerschnitzel“ starts with a vowel. The pronunciation at the beginning is pretty close to “yeah,” which I don't think is considered as starting with a vowel in English, either.

The "y" of "yeah" or Jägerschnitzel is the "palatal approximant", international phonetic alphabet [j]. "palatal approximant" is not one precise thing: it is the term used for a sound the approximates a sound from a different language. The exact role of [j] varies with language and dialect and what is being approximated. But one of the roles in English with particular reference to German words that begin with that the sound being discussed, is as a "semi-vowel", which is a vowel that cannot stand on its own as a syllable.

That said, it is true that at the time I posted I was getting confused between the semi-vowel role of English "y" as in "yes" and "yellow", and the full-vowel role such as in "why" or "ytterbium".

If the question were rephrased in terms of "starting with something that is not strictly a consonant" or in terms of "starting with something that is strictly a vowel" then the the results would be different. But if we talk about strict vowels then some of the diphthong combinations of a, e, i, o, u would probably not make the cut.

The problem with these questions is that they inevitably ask about "vowels", which is a linguistic category with lots of room for argument, instead of asking about "letters", which is much better defined.

I have posted before demonstrating that even "w" can be a vowel in English -- most notably in some fairly uncommon words borrowed from Welsh. But because English is not prescriptive, words from Old English are still technically valid, even if rarely used, and in Old English "w" could represent a vowel. It just happens that we do not need to consider "w" in the context of words starting with vowels because it was, if I understand properly, not used in vowel form at the beginning of words.

Sign in to comment.

Categories

Tags

Asked:

on 27 Mar 2018

Commented:

on 27 Mar 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!