LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect last by one vowels in an array

Hi Guys!

 

I need help in building a VI which detects the last by one vowel in a word and then it executes specific actions depending on the vowel.

 

I have an array like this:

Peti    Teri
Zoli    Hajni
Tomi    Heni
Pali    Robi

 

(These are Hungarian words, it is not important)

 

So the VI should observ the last by one vowel in every word, and if it is "a,o,u" it executes an action; if it is "e,i" it executes another action.

 

I would appreciate your help. Thank you in advance!

 

 

0 Kudos
Message 1 of 12
(5,421 Views)

Is this a 2D array or a 1D array with two words per element? If it is a 2D array, does it matter in what order the words are inspected?

What is "last by one"? Maybe it would be easier if you could tell us which vovels would result from your example array.

0 Kudos
Message 2 of 12
(5,391 Views)

It is a 2D array. Actually only the second column should be examined.

The last by one vowels in the second column are: e,a,e,o; in this order.

0 Kudos
Message 3 of 12
(5,381 Views)

Last by one = next to last?

0 Kudos
Message 4 of 12
(5,367 Views)

123456789

 

In this sequence the last by on number is number „8”; So it's not the last, but the previous one.

0 Kudos
Message 5 of 12
(5,364 Views)

Maybe it's a quirk in the Hungarian language.  But "last by one" doesn't mean anything in English.  The correct phrase (as stated earlier) is "next to last".

0 Kudos
Message 6 of 12
(5,351 Views)

This VI should give you an idea of what to do to extract the vowel from a word, from here it is just a matter of working out what you want to do with relation to the arrays and the appropriate method to perform actions from the developed vowel.

 

Vowel Seeker.jpg

0 Kudos
Message 7 of 12
(5,335 Views)

After several decades of programming, especially recently some complex LabVIEW routines, I've become a great fan of doing the initial programming in Microsoft Word, i.e. "Write the documentation first".  What do you need to do?  tf I were writing the documentation, I'd identify several sub-tasks (which I'd code as separate sub-VIs).  First, given a string, return an array that indicates the position of all of the vowels.  That is, if the word is "stage", you should get the array [2, 4], while if it is "bcdggh", it will be an empty array.  Step two is to extract the next-to-last vowel, but the previous step should show you that you need to think about "What if there is 0 or only 1 vowels?".  If you have an array of vowel indices, and the length is > 1, getting the next-to-ast vowel is easy.

 

So how do you find all the volowls?  The Match Pattern function, with a search string of [AEIOUaeiou] will split the word if it finds a vowel, and will return a value related to the vowel position.  A useful trick is to write a little LabVIEW program with just this function, wire constants to the inputs, and look at the outputs.  By cleverly using a While loop and shift registers, you should be able to put your chosen word as the input, have it come out unchanged at the other end, and have an array of vowel positions.  [Note that right after Match Pattern splits the word for you, you can use Concatenate Strings to put it back together, so the loop is always looking at the entire word.]

 

BS

0 Kudos
Message 8 of 12
(5,318 Views)

Dear Istvan, 

 

The fastest soultion in this case would be to just reverse the string and look for the first vowel. Here's an example code, and as you can see it is rather simple:

Find last vowel.png

Alternatively, you can write a custom regular expression to make the search on the original string array.

 

Kind regards: 

Andrew Valko
National Instruments Hungary
0 Kudos
Message 9 of 12
(5,297 Views)

Edit:

 

I just noticed that you need the second to last vowel ere. This just means that the regular expression needs to be a little modified, something like:

Find second to last vowel.png

 

Regards:

Andrew Valko
National Instruments Hungary
0 Kudos
Message 10 of 12
(5,285 Views)