
getInputQuestion(ScreenedList) :-
	getText(InputText),
	parseTextToList(InputText, InputList),
	screenLexicon(InputList, ScreenedList).


getText([HeadChar|InputText]) :-
	get0(HeadChar),
	HeadChar =\= 10,
	!,
	getText(InputText).
getText([]).


parseTextToList([],[]).
parseTextToList(Text, [Word|List]) :-
	removeWord(Text, StringWord, RemainingText),
	string_to_list(Word, StringWord),
	parseTextToList(RemainingText, List),
	!.

removeWord([], [], []).
removeWord([Char|Remainder], [], Remainder) :-
	Char == 32.
removeWord([Char|TempRemainder], [ScreenedChar|Word], Remainder) :-
	Char =\= 32,
	validChar(Char),
	screenChar(Char, ScreenedChar),
	removeWord(TempRemainder, Word, Remainder).
removeWord([Char|TempRemainder], Word, Remainder) :-
	Char =\= 32,
	\+ validChar(Char),
	removeWord(TempRemainder, Word, Remainder).

screenChar(Char, ScreenedChar) :-
	uppercase(Char),
	ScreenedChar is (Char + 32),
	!.
screenChar(Char, ScreenedChar) :-
	(lowercase(Char);numeric(Char)),
	ScreenedChar = Char,
	!.

validChar(Char) :-
	uppercase(Char) ; lowercase(Char); numeric(Char). 

uppercase(Char) :-
	Char > 64,
	Char < 91.
lowercase(Char) :-
	Char > 96,
	Char < 123.
numeric(Char) :-
	Char > 47,
	Char < 58.


screenLexicon([],[]).
screenLexicon([Head|InputList],[Head|OutputList]) :-
	string_to_list(Head, ListHead),
	kb_rule(ListHead, _),    
	screenLexicon(InputList, OutputList).
screenLexicon([Head|InputList],OutputList) :-
	string_to_list(Head, ListHead),
	\+kb_rule(ListHead, _),  
	screenLexicon(InputList, OutputList).

