Josephine E. Petralba
josephinepetralba@apps.usjr.edu.ph | jepetralba@gmail.com
IEEE Publication
Top

These are Stored Functions for Word Games. All stored functions are written in Oracle PL/SQL.

A. Function Name: SF_CNT_IN_SET_RATIO
Description:
FUNCTION SF_CNT_IN_SET_RATIO
( in_string in varchar2, set_belong in varchar2) return number /* returns the ratio of the the occurrence of any character in set_belong with respect to the length of in_string */
Example:
select sf_cnt_in_set_ratio( 'abecd', 'aeiouAEIOU ') from dual;
Return: 0.4
Explanation:
Number of vowels in in_string = 2 Length of in_string=5 Ratio=2/5=0.4 Principle:
The number of vowels is directly proportional to the ratio. The lower the ratio of a word, the more difficult for that word to be guessed in Hangaroo or used in some Word Games. In hangaroo for example, players tend to guess the vowels first.

B. Function Name: SF_CNT_NOT_IN_SET_CONSECUTIVE
Description:
FUNCTION SF_CNT_NOT_IN_SET_CONSECUTIVE
( in_string in varchar2, set_belong in varchar2) return number /* returns the length of the longest consecutive string of characters in in_string not belonging to any character in set_belong */
Example:
select sf_cnt_not_in_set_consecutive( 'abecdfgha', 'aeiouAEIOU-/.'' ') from dual;
Return: 5
Explanation:
The parameter set_belong takes in a string 'aeiouAEIOU-/.'' ', which is a string of vowels and some special characters. 'cdfgh' is the longest consecutive string of characters in in_string that does not have any vowel Length of 'cdfgh'=5
Principle:
The longer a substring having consecutive consonants, is in a word, the more difficult for that word to be guessed or used in a Word Game. This function returns 5 for 'cryptic' and '2' for 'somebody'

C. Function Name: SF_EXCLUDING_CHARS
Description:
FUNCTION SF_EXCLUDING_CHARS
( in_string in varchar2, in_excluded_char in varchar2) return number /* return 0 if in_string has excluded characters 1 otherwise */
Example:
select sf_excluding_chars('abcd', '0123456789') from dual;
Return: 1
Explanation:
'abcd' does not contain a digit so it returns 1
Principle:
This function is used to query for words that are restricted only to some character sets. In a word game, we may only consider words that must not have digits.

D. Function Name: SF_STR_LEN
Description:
function SF_STR_LEN ( in_string in varchar2) return number /*returns the length of string excluding space, - / . '*/
Example:
select SF_STR_LEN ('ab cde-g') from dual; Return: 6
Explanation:
We only consider the letter in getting the string length. There are 6
Principle:
The longer the string, the more difficult it may be that word is guessed or used in Word Games. The predefined string length function in SQL or in most programming languages does not exclude blank spaces in its length functions. For example the length of string: ' free ' is 12, since blank spaces are included. If you exclude the spaces, length is 4. The predefined string length function would misled the implication that the longer strings are more difficult. What if it has many blank spaces like the example above. Thus, SF_STR_LEN was created to relieve such wrong implications brought about by predefined string length functions.