Hi,
I’ve got this code:
abbreviate(Sentence, Acronym) :-
split_string(Sentence, "- ", " \t\n", PhraseList),
maplist(remove_non_alphanumeric, PhraseList, CleanList),
maplist(first_char, CleanList, AcronymList),
atomic_list_concat(AcronymList, AcronymString),
upcase_atom(AcronymString, Acronym).
remove_non_alphanumeric(String, CleanString) :-
atom_chars(String, Chars),
include(alpha_numeric_char, Chars, AlphaNumericChars),
atom_chars(CleanString, AlphaNumericChars).
alpha_numeric_char(Char) :-
char_type(Char, alpha);
char_type(Char, digit).
first_char(String, Char) :-
atom_chars(String, [Char|_]).
When I test it interactively it works. However when I run the test, it fails with errors similar to:
ERROR:
[[ EXCEPTION while printing message url('/mnt/exercism-iteration/acronym_tests.plt':9)
with arguments []:
raised: type_error(text,url('/mnt/exercism-iteration/acronym_tests.plt':9))
]]
:
test basic: failed
I’m completely new to Prolog but do have lots of experience with other programming likes like Python. Thanks in advance for your help on this.