Hello guys,
I want to create a loop which goes through the cases whose variable X for example contains a text like "texteArechercher".
What operator is used to find all of the words that resemble the words to search for ?
thanks advance
what is the equivalent of operator LIKE in CSPro ?
Re: what is the equivalent of operator LIKE in CSPro ?
Dear Mosbi,
The nearest functions equivalent to LIKE are
1) https://www.csprousers.org/help/CSPro/pos_function.html
2) https://www.csprousers.org/help/CSPro/s ... ction.html
Hope this help you!
The nearest functions equivalent to LIKE are
1) https://www.csprousers.org/help/CSPro/pos_function.html
2) https://www.csprousers.org/help/CSPro/s ... ction.html
Hope this help you!
G.VOLNY, a CSProuser from Haiti, since 2004
Re: what is the equivalent of operator LIKE in CSPro ?
Hi Mosbi,
>What operator is used to find all of the words that resemble the words to search for ?
I'm not sure what you mean by 'resemble'. Must the similar word be identical except for an extra or missing letter? Or does the similar word just have to contain all or nearly the same letters? If the latter, you could count the # of letters that appear in each string, and see how the counts compare.
Otherwise, in addition to the two functions HTUser mentioned, the poschar function might be of value.
https://www.csprousers.org/help/CSPro/p ... ction.html
Sherrell
>What operator is used to find all of the words that resemble the words to search for ?
I'm not sure what you mean by 'resemble'. Must the similar word be identical except for an extra or missing letter? Or does the similar word just have to contain all or nearly the same letters? If the latter, you could count the # of letters that appear in each string, and see how the counts compare.
Otherwise, in addition to the two functions HTUser mentioned, the poschar function might be of value.
https://www.csprousers.org/help/CSPro/p ... ction.html
Sherrell
Re: what is the equivalent of operator LIKE in CSPro ?
Hello,
Basically I mean, an operator that can search for a string in a column of a table, ignoring upper and lower case letters.
for example:
search word: "Ouedraogo Boureima"
example answer found:
- ouedraogo boureima
- stuffed ouédrago
- ouedraogo Boureima28
- ouedraogoboureima
- etc .....
You see ?
In a web programming language for example, the "LIKE" operator allows you to do this.
But I am wondering with CSPro, what trick can I use to have the same result?
Thank you.
Basically I mean, an operator that can search for a string in a column of a table, ignoring upper and lower case letters.
for example:
search word: "Ouedraogo Boureima"
example answer found:
- ouedraogo boureima
- stuffed ouédrago
- ouedraogo Boureima28
- ouedraogoboureima
- etc .....
You see ?
In a web programming language for example, the "LIKE" operator allows you to do this.
But I am wondering with CSPro, what trick can I use to have the same result?
Thank you.
Re: what is the equivalent of operator LIKE in CSPro ?
Hi Mosbi,
Sorry, we don't provide functions that delve into string processing to this level. You'd have to find an algorithm and code it in CSPro. Here are two posts that use the Levenshtein Distance algorithm to do this.
https://stackoverflow.com/questions/104 ... -of-likely
https://people.cs.pitt.edu/~kirk/cs1501 ... stance.htm
CSPro does have a regex matching function, but this would require regex skills:
https://www.csprousers.org/help/CSPro/r ... ction.html
Finally, Greg gave me the following code block that he & Josh used a few years back:
Sorry, we don't provide functions that delve into string processing to this level. You'd have to find an algorithm and code it in CSPro. Here are two posts that use the Levenshtein Distance algorithm to do this.
https://stackoverflow.com/questions/104 ... -of-likely
https://people.cs.pitt.edu/~kirk/cs1501 ... stance.htm
CSPro does have a regex matching function, but this would require regex skills:
https://www.csprousers.org/help/CSPro/r ... ction.html
Finally, Greg gave me the following code block that he & Josh used a few years back:
// based on https://en.wikipedia.org/wiki/Damerau%E ... n_distance
array d(51, 51);
function dlDistance(string a, string b)
numeric i, j, cost, trans;
do i = 0 while i <= length(a)
d(i, 0) = i;
enddo;
do j = 0 while j <= length(b)
d(0 , j) = j;
enddo;
do i = 1 while i <= length(a)
do j = 1 while j <= length(b)
if a[i:1] = b[j:1] then
cost = 0;
else
cost = 1;
endif;
if i > 1 and j > 1 and a[i-1:1] = b[j-2:1] and a[i-2:1] = b[j-1:1] then
trans = d(i - 2, j - 2) + cost;
else
trans = length(a) + length(b);
endif;
d(i, j) = low( d(i - 1, j) + 1,
d(i,j-1) + 1,
d(i-1, j-1) + cost,
trans);
enddo;
enddo;
dlDistance = d(length(a), length(b));
end;
Sherrellarray d(51, 51);
function dlDistance(string a, string b)
numeric i, j, cost, trans;
do i = 0 while i <= length(a)
d(i, 0) = i;
enddo;
do j = 0 while j <= length(b)
d(0 , j) = j;
enddo;
do i = 1 while i <= length(a)
do j = 1 while j <= length(b)
if a[i:1] = b[j:1] then
cost = 0;
else
cost = 1;
endif;
if i > 1 and j > 1 and a[i-1:1] = b[j-2:1] and a[i-2:1] = b[j-1:1] then
trans = d(i - 2, j - 2) + cost;
else
trans = length(a) + length(b);
endif;
d(i, j) = low( d(i - 1, j) + 1,
d(i,j-1) + 1,
d(i-1, j-1) + cost,
trans);
enddo;
enddo;
dlDistance = d(length(a), length(b));
end;
Last edited by sherrell on October 21st, 2021, 12:11 pm, edited 1 time in total.
Re: what is the equivalent of operator LIKE in CSPro ?
Hi Mosbi,
In addition to responses provided by Sherrell,
1) Please take a look in the CSPro folder in your My Documents: Documents\CSPro\Examples 7.6\1 - Data Entry\Selecting Cases
Selecting Cases seem exactly what you're looking for, mainly, option 5.
2) Autocompletion can also help you. Here's a discussion with Greg, years ago:https://www.csprousers.org/forum/viewto ... lete#p2197 . Greg used the same logic from the Selecting Cases. But, there's a more convenient way to do it using Javascript and future htmlDialog function.
3) Also, it seem that your demand is more concerned by full-text search. In the next version, CSPro will have a Javascrit-CSPro interface. That's mean, you'll be able to run CSPro Logic function inside Javascript and also, return result from Javascript to CSPro.
Please for Javascript full-text search, take a look here:
https://burakkanber.com/blog/machine-le ... e-scoring/
https://stackoverflow.com/questions/113 ... -and-html5
https://github.com/nextapps-de/flexsearch
With the next Javascrit-CSPro interface, it's virtually impossible to have a CSProuser request who can't be fulfilled since JavaScript is the language having the greatest know open libraries.
@ Sherrell, as it's always more convenient to have example and demo in CSPro logic, please can you provide us a small demo app with codes you posted?
Hope this help you
In addition to responses provided by Sherrell,
1) Please take a look in the CSPro folder in your My Documents: Documents\CSPro\Examples 7.6\1 - Data Entry\Selecting Cases
Selecting Cases seem exactly what you're looking for, mainly, option 5.
2) Autocompletion can also help you. Here's a discussion with Greg, years ago:https://www.csprousers.org/forum/viewto ... lete#p2197 . Greg used the same logic from the Selecting Cases. But, there's a more convenient way to do it using Javascript and future htmlDialog function.
3) Also, it seem that your demand is more concerned by full-text search. In the next version, CSPro will have a Javascrit-CSPro interface. That's mean, you'll be able to run CSPro Logic function inside Javascript and also, return result from Javascript to CSPro.
Please for Javascript full-text search, take a look here:
https://burakkanber.com/blog/machine-le ... e-scoring/
https://stackoverflow.com/questions/113 ... -and-html5
https://github.com/nextapps-de/flexsearch
With the next Javascrit-CSPro interface, it's virtually impossible to have a CSProuser request who can't be fulfilled since JavaScript is the language having the greatest know open libraries.
@ Sherrell, as it's always more convenient to have example and demo in CSPro logic, please can you provide us a small demo app with codes you posted?
Hope this help you
G.VOLNY, a CSProuser from Haiti, since 2004
Re: what is the equivalent of operator LIKE in CSPro ?
> Sherrell, as it's always more convenient to have example and demo in CSPro logic, please can you provide us a small demo app with codes you posted?
I'm just the messenger. Greg is off this week, but saw our convo on this and sent me the code snippet. Since it was part of a larger app, he would have to (no doubt) make a lot of edits to isolate just the portion that was relevant to Mosbi's request.
Sherrell
I'm just the messenger. Greg is off this week, but saw our convo on this and sent me the code snippet. Since it was part of a larger app, he would have to (no doubt) make a lot of edits to isolate just the portion that was relevant to Mosbi's request.
Sherrell
Re: what is the equivalent of operator LIKE in CSPro ?
Thanks Sherrell.
I'll discuss with Greg once he come back to office.
Best,
I'll discuss with Greg once he come back to office.
Best,
G.VOLNY, a CSProuser from Haiti, since 2004
Re: what is the equivalent of operator LIKE in CSPro ?
Hello,
Really happy for the quick reaction from you, it's motivating.
Now I will try the Documents \ CSPro \ Examples 7.6 \ 1 - Data Entry \ Selecting Cases application, while waiting for the arrival of Javascript which will really revolutionize CSPro!
I do the tests and I will come back to you !!!
Thank you.
Really happy for the quick reaction from you, it's motivating.
Now I will try the Documents \ CSPro \ Examples 7.6 \ 1 - Data Entry \ Selecting Cases application, while waiting for the arrival of Javascript which will really revolutionize CSPro!
I do the tests and I will come back to you !!!
Thank you.
Re: what is the equivalent of operator LIKE in CSPro ?
Hello,
Like I said, I tried the "pos" function but it doesn't seem to work well with the "forcase" function.
In my current situation, I need to loop through data in a table. and in this case I use a "forcase"
in the "forcase", when I add the function "pos" as a criterion, my request does not return a result, whereas there is indeed a line of data which corresponds to the name that I have put in the function " pos ".
Is there really an incompatibility between "forcase" and "pos"?
if no compatibility problem, how can i convert my query to what works?
below my request:
forcase BASE_BENEF_REF_DICT where COM_REF = F66_DRAFT And VILLAGE_REF = F67_DRAFT And strip (SEXE) = "Feminin" And pos (strip (F69_DRAFT), toupper (NOM_PRENOMS_INDIVIDUS)) = 1 do
F69_DRAFT: is a name and firstname entered by the agent
NOM_PRENOMS_INDIVIDUS: is the name and firstname present in the database
Thank you.
Like I said, I tried the "pos" function but it doesn't seem to work well with the "forcase" function.
In my current situation, I need to loop through data in a table. and in this case I use a "forcase"
in the "forcase", when I add the function "pos" as a criterion, my request does not return a result, whereas there is indeed a line of data which corresponds to the name that I have put in the function " pos ".
Is there really an incompatibility between "forcase" and "pos"?
if no compatibility problem, how can i convert my query to what works?
below my request:
forcase BASE_BENEF_REF_DICT where COM_REF = F66_DRAFT And VILLAGE_REF = F67_DRAFT And strip (SEXE) = "Feminin" And pos (strip (F69_DRAFT), toupper (NOM_PRENOMS_INDIVIDUS)) = 1 do
F69_DRAFT: is a name and firstname entered by the agent
NOM_PRENOMS_INDIVIDUS: is the name and firstname present in the database
Thank you.