Lets say we have this text
The 85 kilos guy rant 10 miles and then we can se he is simply dummy text of the printing and typesetting industry and all of this in 2 hours
And we want to capture:
-
85 kilos
-
10 miles
-
2 hours
I was trying think of a functions that could retrieve som atributes (atributes known already, of corse)
Lets say we want to detect:
Atribute: [amount] [mesure]
And our mesures are:
[miles, seconds, hours, minutes, times, kilos]
So i was thinking to explode the text in blankspaces, check if word in array (of mesures) and if previous word is a number, then i have an Atribute 😀
(this is kind of pseudo/javascript code)
function get_mesure_attrs(txt){
var text = txt.split(' ');
for (i=1;i<=text.length;i++{ /*Note i begin with i=1 cause the first word would never be a mesure of a desired atribute */
if(text[i] is in_array(mesures){
if(is_number(text[i-1]){
console.log('Atribute: '+text[i-1]+' '+text[i]);
}
}
}
I have no enough familarisation with related asociative arrays, so i was wondering if someone could give me a hint,
thanks a lot
for advance request