Skip to content
Alexandre Rademaker edited this page Jan 6, 2019 · 4 revisions

to obtain the output in the format used by Freeling (https://github.com/TALP-UPC/FreeLing/blob/master/data/pt/senses30.src):

  • perform this query
select ?s ?w {
  graph source:own-pt.nt {
      ?ss wn30:containsWordSense/wn30:word/wn30:lexicalForm ?w ;
          wn30:synsetId ?id .
  }
  BIND (str(?ss) as ?s)
}
order by ?s

The CL lisp code for produce the senses30.src is the one below:

(with-open-file (out "senses30.src" :direction :output :if-exists :supersede)
	   (labels ((print-hash-entry (key value)
		      (format out "~a ~{~a~^ ~}~%" key (sort value #'string<=))))
	     (let ((tb (make-hash-table :test #'equal)))
	       (mapcar (lambda (e)
			 (let ((k (car e))
			       (v (substitute #\_ #\Space (string-downcase (cadr e)))))
			   (if (gethash k tb nil)
			       (push v (gethash k tb))
			       (setf (gethash k tb) (list v)))))
		       (cl-csv:read-csv #P"query.csv"))
	       (maphash #'print-hash-entry tb))))

Clone this wiki locally