:- dynamic wd/2, tag/2, tag/3. :- discontiguous(wd/2, tag/2, tag/3). %%% DATA REPRESENTATION wd(1,'Should'). tag(1,md). tag(md,md,1). wd(2, I). tag(2,pn). tag(pn,pn,2). wd(3, apologize). tag(3,vbp). tag(vbp,vb,3). wd(4, for). tag(4,in). tag(in,in,4). wd(5, the). tag(5,dt). tag(dt,dt,5). wd(6, wait). tag(6,vb). tag(vb,nn,6). wd(7, '?'). tag(7,'.'). tag(.,.,7). %%% TEMPLATES %Condition the transformation rule on... pos:A>B <- pos:C@[-1,-2]. % current pos and any of the two previous pos pos:A>B <- wd:C@[-1]. % current pos and previous word %%% LEARNED RULES %When tagging new data from a baseline... pos:vbp>vb <- pos:md@[-1,-2]. % retag vbp to vb when any of the two previous pos is "md" pos:vb>nn <- wd:the@[-1]. % retag vb to nn when the previous word is "the"