📄 readin.pro
字号:
% File readin.pl - Prolog program to read in a file of sentences
% using built in library(readin)
% To use readin from standard input, used CTRL-D for eol, CTRL-Z for eof
% readin tokenizes words on blanks, punctuations, and white spaces and
% removes whitespaces. readin reads up to 1st line that ends in '.'
% See reference manual for more details
:- ensure_loaded(library(readin)).
%process: current input stream is assumed to have been established before
process :- % used to read in sentence using Prolog library read_in
% repeat is a procedural predicate used for iteration
repeat, %repeat until the complete file is processed
read_in(X), %creates list X using library builtin
(X = end_of_file, seen, !;
X = [''], seen, !;
test(X,F), %test is a predicate that can be used to process sentence
fail
).
%process: established Infile as current input stream before processing
process(Infile) :- see(Infile), process.
%test(+Sentence,-ProcessedSentence) is a predicate for testing sentence readin
% It writes out sentence to standard output
test(S,S) :- write(S), %this could be substituted with a predicate that processes S
nl.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -