-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprolog-import.lisp
567 lines (527 loc) · 20.9 KB
/
prolog-import.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
;;; Documentation for the Prolog export format:
;;; http://www2.parc.com/isl/groups/nltt/xle/doc/xle.html
;;; Limitations:
;;; - Expects completely disambiguated files.
;;; - Expects the "selected" solution to have index 1, eg. select(A3,1).
;;; Tell SBCL we want full debugging info (eg. no function inlining),
;;; but don't care about speed:
(declaim (optimize (speed 0) (safety 3) (debug 3)))
(in-package #:lfgalign)
(defun parse-args (stream)
"Helper for parse-pred."
(let* ((rv (parse-pred stream))
(prevc (car rv))
(args (cdr rv)))
(if (or (eq prevc #\))
(eq prevc #\])
;; can we get the dot here?
(eq prevc #\.))
(return-from parse-args (list args))
(let ((allargs (cons args
(parse-args stream))))
(return-from parse-args allargs)))))
(defun parse-pred (stream)
"Create a list structure from a Prolog file by reading `stream'
character by character (would be faster if we slurp:
http://www.ymeme.com/slurping-a-file-common-lisp-83.html). This
function assumes that the next thing we see in the stream (apart from
comments) is a clause head or atom; ie. it shouldn't start within an
argument list, that's for the helper function `parse-args' to
handle. This function reads one clause head or atom (predicate of zero
arity), lets `parse-args' handle possible arguments, and then returns.
Returns a pair of the previous character and the created list
structure."
(let ((instring nil)
(args nil)
(lastc nil)
(head (make-array 0
:element-type 'character
:fill-pointer 0
:adjustable t)))
(do ((c (read-char stream) (read-char stream nil 'eof)))
((eq c 'eof))
(if instring
(case c
(#\'
(unless (eq lastc #\\) (setq instring nil))
(vector-push-extend c head))
(otherwise
(vector-push-extend c head)))
(case c
(#\' (setq instring t)
(vector-push-extend c head))
(#\% (read-line stream))
(#\( (setq args (parse-args stream)))
(#\[ (setq args (parse-args stream))
(setq head 'list))
((#\, #\) #\] #\.)
(return (cons c (cons head args))))
((#\Tab #\Newline #\ )
t)
(otherwise
(vector-push-extend c head))))
(setq lastc c))))
(defun disambiguated? (raw)
"Signal an error if the file has more than one solution."
(let ((selected (mapcar-true
(lambda (x)
(and (equal "select" (first x))
;; TODO: will we ever care about non-1's?
(equal '("1") (third x))
(car (second x))))
(raw-equiv raw)))
(choices (mapcar-true
(lambda (x)
(and (equal "choice" (first x))
(cons (car (third x)) (mapcar #'car (cdr (second x))))))
(cdr (fourth raw)))))
(or (do*
((current "1" ; TODO: will the intersection ever have >1?
(car (intersection (cdr curchoice) selected :test #'equal)))
(curchoice (assoc current choices :test #'equal)
(assoc current choices :test #'equal)))
((not curchoice) current))
(error ">1 solutions, selected: ~A, choices: ~A" selected choices))))
(defun parse-prolog (stream)
(let* ((raw (cdr (parse-pred stream))))
(and (disambiguated? raw)
raw)))
(defun raw-sentence (parse)
(second parse))
(defun raw-equiv (parse)
"Skip the first element, LIST."
(cdr (fifth parse)))
(defun raw-f-str (parse)
"Skip the first element, LIST."
(cdr (sixth parse)))
(defun raw-c-str (parse)
"Skip the first element, LIST."
(cdr (seventh parse)))
(defun in-disjunction (goals disjuncts)
"See if any of the `disjuncts' are members of `goals'."
(cond ((not (consp disjuncts)) (member disjuncts goals :test #'equal))
((equal (car disjuncts) "and") (error 'unexpected-input disjuncts))
((equal (car disjuncts) "or") (in-disjunction goals (cdr disjuncts)))
(t (or
(in-disjunction goals (car disjuncts))
(in-disjunction goals (cdr disjuncts))))))
(defun clean-equiv (raw-equiv)
"Runs on `raw-equiv' output to create a list of Prolog variable
names which are equivalent to \"1\" (our selected parse)."
(let ((select1s
(mapcar-true (lambda (x)
(and (equal "select" (first x))
(equal "1" (car (third x)))
(car (second x))))
raw-equiv)))
(append '("1")
select1s
(mapcar-true (lambda (x)
(and (equal "define" (first x))
(or (not (fourth x)) (error 'unexpected-input x))
(in-disjunction select1s (third x))
(car (second x))))
raw-equiv))))
(defun filter-equiv (raw-equiv raw-cf)
"Use on input to `clean-f-str' and `clean-c-str' to remove cf's
which are not part of the selected parse."
(let ((equivs (clean-equiv raw-equiv)))
(remove-if (lambda (cf)
(not (in-disjunction equivs (second cf))))
raw-cf)))
(defun clean-var (varnum)
"Helper for `clean-f-str' and `clean-c-str'."
(if (equal (car varnum) "'NULL'")
"NULL"
(parse-integer (caadr varnum))))
(defun clean-car/var (list)
"Turn both 1 and var(1), i.e. (\"1\") and (\"var\" \"1\"), into 1;
return Prolog strings as strings, i.e. \"'PRED'\" to \"PRED\"."
(let ((elt (car list)))
(cond ((eq (intern elt) '|var|)
(clean-var list))
((cdr list) ; if not var, we expect only one element
(error list))
((eq #\' (aref elt 0))
(subseq elt 1 (1- (length elt))))
((equal "-" elt)
nil)
(t
(parse-integer elt)))))
(defun clean-pred (semform)
"Helper for `clean-f-str'."
(list (clean-car/var (second semform))
(clean-car/var (third semform))
(if (not (equal (cadr (fourth semform)) '("")))
(mapcar #'clean-var (cdr (fourth semform))))
(if (not (equal (cadr (fifth semform)) '("")))
(mapcar #'clean-var (cdr (fifth semform))))))
(defun clean-att-val (lhs rhs)
"Helper for `clean-f-str'."
(cons (clean-car/var lhs)
(if (eq (intern (car rhs)) '|semform|)
(clean-pred rhs)
(clean-car/var rhs))))
(defun clean-f-str (raw-f)
"Runs on `raw-f-str' output. Creates a pseudo-alist,
each var is a key but appears once for each attribute/projection etc.,
see `dup-alist-to-table' and `table-to-alist'."
(mapcar
(lambda (cf)
(let* ((assig (third cf))
(lhs (second assig))
(rhs (third assig)))
(case (intern (first assig))
(|eq|
(case (intern (car lhs))
(|var|
(list '|eqvar|
(clean-att-val lhs rhs)))
(|attr|
(list (clean-var (second lhs))
(clean-att-val (third lhs) rhs)))
(|proj|
(list (clean-var (second lhs))
(clean-att-val (third lhs) rhs)))))
(|in_set|
(list '|in_set|
(clean-att-val lhs rhs))))))
raw-f))
(defun attvalp (attval)
(and (listp attval)
(listp (cdr attval))
(cdr attval)
(listp (second attval))
(not (cddr attval))))
(defun clean-c-str (raw-c)
"Runs on `raw-c-str' output. Creates a pseudo-alist, each type is a
key but appears once for each attribute etc., see `dup-alist-to-table'
and `table-to-alist'."
(mapcar
(lambda (cf)
(let* ((assig (third cf))
(type (intern (car assig)))
(id (clean-car/var (second assig)))
(rest (cddr assig)))
(list type
(cons id
(case type
(|terminal| (list (clean-car/var (first rest))
(mapcar #'clean-car/var (cdr (second rest)))))
(|phi| (clean-car/var (first rest)))
(|cproj| (clean-car/var (first rest)))
(t (mapcar #'clean-car/var rest)))))))
raw-c))
(defun dup-alist-to-table (dup-alist &optional no-eq-sets)
"Runs on `clean-f-str' or `clean-c-str' output to create a hash
table so that we can get the full list of attributes by looking up
with the var key."
(let ((table (make-hash-table)))
(dolist (pair dup-alist)
(let ((key (car pair)))
(if (attvalp pair)
(setf (gethash key table)
(cons (second pair) (gethash key table)))
(if (gethash key table)
(error 'unexpected-input key)
(setf (gethash key table)
(cdr pair))))))
(unless no-eq-sets (setf (gethash '|eq-sets| table)
(dset3-collect (gethash '|eqvar| table))))
table))
(defun import-table (stream)
"Convenience function, turn a file-stream into a table where each
key is an f-str variable or a c-structure part (subtree, phi, fspan,
terminal etc.)"
(awhen (parse-prolog stream)
(dup-alist-to-table
(cons (cons '|sentence| (clean-car/var (raw-sentence it)))
(append (clean-f-str (filter-equiv (raw-equiv it)
(raw-f-str it)))
(clean-c-str (filter-equiv (raw-equiv it)
(raw-c-str it))))))))
(defun open-and-import (file &optional absolute)
"Convenience function. `file' is relative to the lfgalign directory
unless `absolute' is true."
(with-open-file
(stream
(make-pathname
:name file
:directory (if absolute
'(:absolute)
(pathname-directory
(asdf:component-pathname (asdf:find-system :lfgalign))))))
(import-table stream)))
(defun table-to-alist (table &optional print)
"Convenience function, turn a hash table into an association list
(printing it nicely along the way if `print' is true)."
(loop for value being the hash-values of table
using (hash-key key)
do (when print (format t "~&~A -> ~A" key value))
collect (cons key value)))
;;;;;;;; TESTING:
;;;;;;;; --------
(lisp-unit:define-test test-clean-c
(lisp-unit:assert-equal
;; can we assume all subtrees are (at most) binary?
'((|subtree| (19 "AInt_BASE" NIL 20)))
(clean-c-str '(("cf" ("1") ("subtree" ("19") ("'AInt_BASE'") ("-") ("20"))))))
(lisp-unit:assert-equal
'((|subtree| (387 "ROOT" 385 38)))
(clean-c-str '(("cf" ("1") ("subtree" ("387") ("'ROOT'") ("385") ("38"))))))
(lisp-unit:assert-equal
'((|terminal| (1 "abramsma" (1))))
(clean-c-str '(("cf" ("1") ("terminal" ("1") ("'abramsma'") (LIST ("1")))))))
(lisp-unit:assert-equal
'((|phi| (387 . 0)))
(clean-c-str '(("cf" ("1") ("phi" ("387") ("var" ("0")))))))
(lisp-unit:assert-equal
'((|cproj| (34 . 13)))
(clean-c-str '(("cf" ("1") ("cproj" ("34") ("var" ("13")))))))
(lisp-unit:assert-equal
'((|semform_data| (0 2 1 9)))
(clean-c-str '(("cf" ("1") ("semform_data" ("0") ("2") ("1") ("9"))))))
(lisp-unit:assert-equal
'((|fspan| (0 1 16)))
(clean-c-str '(("cf" ("1") ("fspan" ("var" ("0")) ("1") ("16"))))))
(lisp-unit:assert-equal
'((|surfaceform| (1 "abramsma" 1 9)))
(clean-c-str '(("cf" ("1") ("surfaceform" ("1") ("'abramsma'") ("1") ("9")))))))
(lisp-unit:define-test test-clean-f
(lisp-unit:assert-equal
'((|in_set| ("NO-PV" . 19)))
(clean-f-str '(("cf" ("1") ("in_set" ("'NO-PV'") ("var" ("19")))))))
(lisp-unit:assert-equal
'((|eqvar| (20 . 2))
(0 ("PRED" . 1)))
(clean-f-str '(("cf" ("1") ("eq"
("var" ("20"))
("var" ("2"))))
("cf" ("1") ("eq"
("attr" ("var" ("0")) ("'PRED'"))
("var" ("1")))))))
(lisp-unit:assert-equal
'((18 ("o::" . 19)))
(clean-f-str '(("cf" ("1") ("eq" ("proj" ("var" ("18")) ("'o::'")) ("var" ("19")))))))
(lisp-unit:assert-equal
'((|eqvar| (1 "bjeffe" 10 ("NULL" 5) NIL))
(|eqvar| (1 "qePa" 10 (3) NIL)))
(clean-f-str '(("cf" ("1")
("eq" ("var" ("1"))
("semform" ("'bjeffe'") ("10") (LIST ("'NULL'") ("var" ("5")))
(LIST ("")))))
("cf" ("1") ("eq"
("var" ("1"))
("semform" ("'qePa'") ("10") (LIST ("var" ("3"))) (LIST (""))))))))
(lisp-unit:assert-equal
'((3 ("PRED" "kata" 8 NIL NIL)))
(clean-f-str '(("cf" ("1") ("eq"
("attr" ("var" ("3")) ("'PRED'"))
("semform" ("'kata'") ("8") (LIST ("")) (LIST (""))))))))
(lisp-unit:assert-equal
'((|eqvar| (20 . "past")))
(clean-f-str '(("cf" ("1") ("eq"
("var" ("20"))
("'past'"))))))
(lisp-unit:assert-equal
'((5 ("CASE" . "erg")))
(clean-f-str '(("cf" ("1") ("eq"
("attr" ("var" ("5")) ("'CASE'"))
("'erg'")))))))
(lisp-unit:define-test test-attvalp
(lisp-unit:assert-true (attvalp '(5 ("'CASE'" . "'erg'"))))
(lisp-unit:assert-false (attvalp '(2 "'qePa-dup'" 10 (3) NIL)))
(lisp-unit:assert-false (attvalp '(20 . "'past'")))
(lisp-unit:assert-false (attvalp '(20)))
(lisp-unit:assert-false (attvalp '20)))
(lisp-unit:define-test test-var/pred
(lisp-unit:assert-eq
3
(clean-var '("var" ("3"))))
(lisp-unit:assert-equal
'("kata" 8 NIL NIL)
(clean-pred '("semform" ("'kata'") ("8") (LIST ("")) (LIST ("")))))
(lisp-unit:assert-equal
'("qePa" 10 (3) NIL)
(clean-pred '("semform" ("'qePa'") ("10") (LIST ("var" ("3"))) (LIST ("")))))
(lisp-unit:assert-equal
'("bjeffe" 10 ("NULL" 5) NIL)
(clean-pred '("semform" ("'bjeffe'") ("10") (LIST ("'NULL'") ("var" ("5"))) (LIST (""))))))
(lisp-unit:define-test test-make-table
(lisp-unit:assert-equal '((|in_set| (|'NO-PV'| 19)))
(table-to-alist (dup-alist-to-table '((|in_set| (|'NO-PV'| 19)))
'no-eq-sets)))
(lisp-unit:assert-equal '((|eqvar| (20 . 2)))
(table-to-alist (dup-alist-to-table '((|eqvar| (20 . 2)))
'no-eq-sets)))
(lisp-unit:assert-equal '((5 (|'CASE'| . |'erg'|)))
(table-to-alist (dup-alist-to-table '((5 (|'CASE'| . |'erg'|)))
'no-eq-sets)))
(lisp-unit:assert-equal '((0 (|'PRED'| . 1)))
(table-to-alist (dup-alist-to-table '((0 (|'PRED'| . 1)))
'no-eq-sets)))
(lisp-unit:assert-equal
'((18 (|'o::'| . 19))
(1 "'bjeffe'" 10 ("'NULL'" 5) NIL)
(3 ("'PRED'" "'kata'" 8 NIL NIL)))
(table-to-alist
(dup-alist-to-table
'((18 (|'o::'| . 19))
(1 "'bjeffe'" 10 ("'NULL'" 5) NIL)
(3 ("'PRED'" "'kata'" 8 NIL NIL)))
'no-eq-sets))))
(lisp-unit:define-test test-disj
(lisp-unit:assert-true
(in-disjunction '("C5") (third '("define" ("CV_010")
("or" ("or" ("D5") ("D1") ("D3")) ("C5") ("or" ("C1") ("C3")) ("B5")
("B1") ("B3")))))))
(lisp-unit:define-test test-equiv
(let ((raw-equiv
(with-open-file
(stream (merge-pathnames "dev/TEST_equiv.pl"
(asdf:component-pathname (asdf:find-system :lfgalign))))
(raw-equiv (parse-prolog stream)))))
(lisp-unit:assert-equal
'("1" "D6" "A3" "CV_004" "CV_005" "CV_007" "CV_008" "CV_009")
(clean-equiv raw-equiv))
(lisp-unit:assert-equal
'((3 ("PRED" "kata" 8 NIL NIL)))
(clean-f-str (filter-equiv raw-equiv
'(("cf" ("A3") ("eq"
("attr" ("var" ("3")) ("'PRED'"))
("semform" ("'kata'") ("8") (LIST ("")) (LIST ("")))))))))
(lisp-unit:assert-false
(clean-f-str (filter-equiv raw-equiv
'(("cf" ("A4") ("eq"
("attr" ("var" ("3")) ("'PRED'"))
("semform" ("'kata'") ("8") (LIST ("")) (LIST ("")))))))))))
(lisp-unit:define-test test-parsefile
(lisp-unit:assert-equal
'("fstructure" ("'abramsma iqePa.'")
(LIST ("'xle_version'" ("'XLE release of Jan 21, 2008 10:36.'"))
("'grammar'" ("'/usr/local/xledir/pargram/kartuli/kartuli.lfg'"))
("'grammar_date'" ("'Oct 28, 2008 23:47'"))
("'statistics'"
("'2+2 solutions, 0.04 CPU seconds, 34 subtrees unified'"))
("'rootcategory'" ("'ROOT'"))
("'max_medial_constituent_weight'" ("'35'"))
("'max_medial2_constituent_weight'" ("'30'")))
(LIST ("")) (LIST (""))
(LIST ("cf" ("1") ("eq" ("attr" ("var" ("0")) ("'PRED'")) ("var" ("1"))))
("cf" ("1") ("eq" ("attr" ("var" ("0")) ("'SUBJ'")) ("var" ("3"))))
("cf" ("1") ("eq" ("attr" ("var" ("0")) ("'CHECK'")) ("var" ("4"))))
("cf" ("1")
("eq" ("attr" ("var" ("0")) ("'TNS-ASP'")) ("var" ("5"))))
("cf" ("1")
("eq" ("attr" ("var" ("0")) ("'CLAUSE-TYPE'")) ("'decl'")))
("cf" ("1") ("eq" ("attr" ("var" ("0")) ("'VFORM'")) ("'fin'")))
("cf" ("1")
("eq" ("var" ("1"))
("semform" ("'qePa'") ("2") (LIST ("var" ("3"))) (LIST ("")))))
("cf" ("1")
("eq" ("attr" ("var" ("3")) ("'PRED'"))
("semform" ("'Abrams'") ("0") (LIST ("")) (LIST ("")))))
("cf" ("1") ("eq" ("attr" ("var" ("3")) ("'CHECK'")) ("var" ("7"))))
("cf" ("1") ("eq" ("attr" ("var" ("3")) ("'NTYPE'")) ("var" ("8"))))
("cf" ("1") ("eq" ("attr" ("var" ("3")) ("'ANIM'")) ("'+'")))
("cf" ("1") ("eq" ("attr" ("var" ("3")) ("'CASE'")) ("'erg'")))
("cf" ("1") ("eq" ("attr" ("var" ("3")) ("'NUM'")) ("'sg'")))
("cf" ("1") ("eq" ("attr" ("var" ("3")) ("'PERS'")) ("'3'")))
("cf" ("1") ("eq" ("attr" ("var" ("7")) ("'_AGR-POS'")) ("'left'")))
("cf" ("1") ("eq" ("attr" ("var" ("8")) ("'NSYN'")) ("'proper'")))
("cf" ("1")
("eq" ("attr" ("var" ("4")) ("'_IN-SITU'")) ("var" ("9"))))
("cf" ("1")
("eq" ("attr" ("var" ("4")) ("'_MORPH-SYNT'")) ("var" ("10"))))
("cf" ("1") ("eq" ("attr" ("var" ("4")) ("'_AGR'")) ("'both'")))
("cf" ("1") ("eq" ("attr" ("var" ("4")) ("'_MAIN-CL'")) ("'+'")))
("cf" ("1") ("eq" ("attr" ("var" ("4")) ("'_PERIOD'")) ("'+'")))
("cf" ("1") ("eq" ("attr" ("var" ("4")) ("'_TENSE'")) ("'aor'")))
("cf" ("1")
("eq" ("attr" ("var" ("4")) ("'_TENSEGROUP'")) ("'aor'")))
("cf" ("1") ("in_set" ("var" ("3")) ("var" ("9"))))
("cf" ("1") ("eq" ("attr" ("var" ("10")) ("'_AGR'")) ("var" ("11"))))
("cf" ("1") ("eq" ("attr" ("var" ("10")) ("'_CLASS'")) ("'MV'")))
("cf" ("1")
("eq" ("attr" ("var" ("10")) ("'_LEXID'")) ("'V2746-3'")))
("cf" ("1") ("eq" ("attr" ("var" ("10")) ("'_PERF-PV'")) ("'-'")))
("cf" ("1") ("eq" ("attr" ("var" ("10")) ("'_SYNTAX'")) ("'unerg'")))
("cf" ("1") ("eq" ("attr" ("var" ("11")) ("'_OBJ'")) ("var" ("12"))))
("cf" ("1") ("eq" ("attr" ("var" ("12")) ("'NUM'")) ("'sg'")))
("cf" ("1") ("eq" ("attr" ("var" ("12")) ("'PERS'")) ("'3'")))
("cf" ("1") ("eq" ("attr" ("var" ("5")) ("'ASPECT'")) ("'perf'")))
("cf" ("1")
("eq" ("attr" ("var" ("5")) ("'MOOD'")) ("'indicative'")))
("cf" ("1") ("eq" ("attr" ("var" ("5")) ("'TENSE'")) ("'past'")))
("cf" ("1") ("eq" ("proj" ("var" ("13")) ("'o::'")) ("var" ("14"))))
("cf" ("1") ("in_set" ("'NO-PV'") ("var" ("14")))))
(LIST ("cf" ("1") ("subtree" ("387") ("'ROOT'") ("385") ("38")))
("cf" ("1") ("phi" ("387") ("var" ("0"))))
("cf" ("1") ("subtree" ("385") ("'ROOT'") ("-") ("381")))
("cf" ("1") ("phi" ("385") ("var" ("0"))))
("cf" ("1") ("subtree" ("381") ("'IPfoc[main,-]'") ("149") ("379")))
("cf" ("1") ("phi" ("381") ("var" ("0"))))
("cf" ("1") ("subtree" ("149") ("'IPfoc[main,-]'") ("-") ("144")))
("cf" ("1") ("phi" ("149") ("var" ("0"))))
("cf" ("1") ("subtree" ("144") ("'PROPP'") ("-") ("2")))
("cf" ("1") ("phi" ("144") ("var" ("3"))))
("cf" ("1") ("subtree" ("2") ("'PROP'") ("-") ("1")))
("cf" ("1") ("phi" ("2") ("var" ("3"))))
("cf" ("1") ("terminal" ("1") ("'abramsma'") (LIST ("1"))))
("cf" ("1") ("phi" ("1") ("var" ("3"))))
("cf" ("1") ("subtree" ("379") ("'Ibar[main,-]'") ("-") ("378")))
("cf" ("1") ("phi" ("379") ("var" ("0"))))
("cf" ("1") ("subtree" ("378") ("'I[main,-]'") ("-") ("177")))
("cf" ("1") ("phi" ("378") ("var" ("0"))))
("cf" ("1") ("subtree" ("177") ("'V'") ("176") ("23")))
("cf" ("1") ("phi" ("177") ("var" ("0"))))
("cf" ("1") ("subtree" ("176") ("'V'") ("175") ("25")))
("cf" ("1") ("phi" ("176") ("var" ("0"))))
("cf" ("1") ("subtree" ("175") ("'V'") ("174") ("27")))
("cf" ("1") ("phi" ("175") ("var" ("0"))))
("cf" ("1") ("subtree" ("174") ("'V'") ("173") ("29")))
("cf" ("1") ("phi" ("174") ("var" ("0"))))
("cf" ("1") ("subtree" ("173") ("'V'") ("172") ("31")))
("cf" ("1") ("phi" ("173") ("var" ("0"))))
("cf" ("1") ("subtree" ("172") ("'V'") ("-") ("33")))
("cf" ("1") ("phi" ("172") ("var" ("0"))))
("cf" ("1") ("subtree" ("33") ("'V_BASE'") ("-") ("34")))
("cf" ("1") ("phi" ("33") ("var" ("0"))))
("cf" ("1") ("terminal" ("34") ("'qePa-2746-3'") (LIST ("21"))))
("cf" ("1") ("phi" ("34") ("var" ("15"))))
("cf" ("1") ("cproj" ("34") ("var" ("13"))))
("cf" ("1") ("subtree" ("31") ("'V_SUFF_BASE'") ("-") ("32")))
("cf" ("1") ("phi" ("31") ("var" ("0"))))
("cf" ("1") ("terminal" ("32") ("'+V'") (LIST ("21"))))
("cf" ("1") ("phi" ("32") ("var" ("0"))))
("cf" ("1") ("subtree" ("29") ("'V_SUFF_BASE'") ("-") ("30")))
("cf" ("1") ("phi" ("29") ("var" ("0"))))
("cf" ("1") ("terminal" ("30") ("'+Unerg'") (LIST ("21"))))
("cf" ("1") ("phi" ("30") ("var" ("0"))))
("cf" ("1") ("subtree" ("27") ("'V_SUFF_BASE'") ("-") ("28")))
("cf" ("1") ("phi" ("27") ("var" ("0"))))
("cf" ("1") ("terminal" ("28") ("'+Aor'") (LIST ("21"))))
("cf" ("1") ("phi" ("28") ("var" ("0"))))
("cf" ("1") ("subtree" ("25") ("'V_SUFF_BASE'") ("-") ("26")))
("cf" ("1") ("phi" ("25") ("var" ("0"))))
("cf" ("1") ("terminal" ("26") ("'+Subj3Sg'") (LIST ("21"))))
("cf" ("1") ("phi" ("26") ("var" ("0"))))
("cf" ("1") ("subtree" ("23") ("'V_SUFF_BASE'") ("-") ("24")))
("cf" ("1") ("phi" ("23") ("var" ("0"))))
("cf" ("1") ("terminal" ("24") ("'+Obj3'") (LIST ("21"))))
("cf" ("1") ("phi" ("24") ("var" ("0"))))
("cf" ("1") ("subtree" ("38") ("'PERIOD'") ("-") ("37")))
("cf" ("1") ("phi" ("38") ("var" ("0"))))
("cf" ("1") ("terminal" ("37") ("'.'") (LIST ("37"))))
("cf" ("1") ("phi" ("37") ("var" ("0"))))
("cf" ("1") ("semform_data" ("0") ("2") ("1") ("9")))
("cf" ("1") ("semform_data" ("2") ("33") ("10") ("14")))
("cf" ("1") ("fspan" ("var" ("0")) ("1") ("16")))
("cf" ("1") ("fspan" ("var" ("3")) ("1") ("9")))
("cf" ("1") ("surfaceform" ("1") ("'abramsma'") ("1") ("9")))
("cf" ("1") ("surfaceform" ("21") ("'iqePa'") ("10") ("15")))
("cf" ("1") ("surfaceform" ("37") ("'.'") ("15") ("16")))))
(with-open-file
(stream (merge-pathnames "dev/TEST_parse.pl"
(asdf:component-pathname (asdf:find-system :lfgalign))))
(parse-prolog stream))))