2013-11-24 32 views
1

如何从用户输入创建单词列表?使用停用字符从用户输入创建列表

例子:

?- readInput(L). 
|: this is an input. this will not be considered 

L=[This, is, an, input, '.'] 

我想要的字符。要么 ?成为句子的结尾,所以后面的所有内容都不在列表中,并且两个停用字符都必须在列表中。

谢谢

回答

2

你想要什么基本上是一个标记,用于其this link可以帮助你。总之,您应该首先将用户输入转换为ASCII码,然后递归解析代码列表,分别处理逗号和空格字符。

如果您使用的是SWI-Prolog,this answer也可以帮助您。