The username under which gitlab is running, has changed from gitlab to git. If you get the following message when pushing or pulling: gitlab@gitlab.ai.vub.ac.be: Permission denied (publickey), then execute this command in your repository directory: git remote set-url origin git@gitlab.ai.vub.ac.be:namespace/project.git . (replace namespace and project by the appropriate values). Use git remote -v to check the current value.

Commit 54cb43bb authored by remivantrijp's avatar remivantrijp

Better handling of conjuncts

parent 87d971a4
......@@ -20,9 +20,10 @@
;;; -------------------------------------------------------------------------------------
(export '(word-dependency-spec
word-dependency-spec-string word-dependency-spec-syn-role word-dependency-spec-unit-name
word-dependency-spec-pos-tag word-dependency-spec-node-id word-dependency-spec-head-id))
word-dependency-spec-pos-tag word-dependency-spec-node-id word-dependency-spec-head-id
word-dependency-spec-conjunct-type))
(defstruct word-dependency-spec string syn-role unit-name pos-tag node-id head-id)
(defstruct word-dependency-spec string syn-role unit-name pos-tag node-id head-id conjunct-type)
;;; Helper functions.
;;; -------------------------------------------------------------------------------------
......
......@@ -74,8 +74,8 @@
("neg" lexical adverbial adverbial "Negation modifier.")
("npadvmod" functional nominal adverbial "NP as adverbial modifier.")
;; Coordination-related modifiers.
("conj" functional nominal conjunt "Conjunct dependent, e.g. John, Mary and Sam")
("cc" conjunction conjunction conjunction "Coordinating conjunction.")
("conj" ignoreable nominal conjunt "Conjunct dependent, e.g. John, Mary and Sam")
("cc" conjunction conjunction "Coordinating conjunction.")
("preconj" conjunction conjunction conjunction "Pre-correlative conjunction.")
;; NP-modifiers.
("nmod" lexical nominal modifier "Unclassified modifier of the head noun.")
......
......@@ -129,6 +129,29 @@
(parent ,parent-name)))))))
subunits)))
(defun handle-functional-conjuncts (function head-word-spec unit-name parent-name word-specs &optional preprocessed-units)
"Handle conjuncts."
(let* ((starter-units (handle-functional-unit function head-word-spec unit-name parent-name word-specs preprocessed-units))
(mother-unit (assoc unit-name starter-units))
(head-word-id (word-dependency-spec-head-id head-word-spec))
(constituents nil)
(other-conjuncts (loop for spec in word-specs
when (and (= (word-dependency-spec-head-id spec) head-word-id)
(string= "conj" (word-dependency-spec-syn-role spec)))
collect spec))
(units-to-append (loop for other-conjunct in (cons head-word-spec other-conjuncts)
for phrase-unit-name = (make-const "conj")
do (push phrase-unit-name constituents)
append (handle-functional-unit function other-conjunct phrase-unit-name (unit-name mother-unit)
word-specs preprocessed-units))))
(cons `(,(unit-name mother-unit)
,@(loop for feature in (unit-body mother-unit)
collect (if (eql 'constituents (feature-name feature))
`(constituents ,constituents)
feature)))
units-to-append)))
;; (comprehend "I like Mickey Mouse and Donald Duck.")
;;;;; ----------------------------------------------------------------------------------------------------------------------
;;;;; CLAUSAL units
;;;;; ----------------------------------------------------------------------------------------------------------------------
......@@ -216,14 +239,20 @@
(first (push (make-const function)
other-functional-unit-names)))))
when unit-name
append (if (clausal-dependent-p function)
(handle-verbal-root word-spec
word-specs
(if (subject-p function)
'clausal-subject 'subclause)
clause-unit-name unit-name preprocessed-units)
(handle-functional-unit
function word-spec unit-name clause-unit-name word-specs preprocessed-units))))
append (cond ((clausal-dependent-p function)
(handle-verbal-root word-spec
word-specs
(if (subject-p function)
'clausal-subject 'subclause)
clause-unit-name unit-name preprocessed-units))
((word-dependency-spec-conjunct-type word-spec)
(handle-functional-conjuncts function word-spec unit-name
clause-unit-name word-specs
preprocessed-units))
(t
(handle-functional-unit
function word-spec unit-name
clause-unit-name word-specs preprocessed-units)))))
(clause-subunits (append (listify subject-unit-name)
(listify object-unit-name)
(listify dative-unit-name)
......@@ -234,31 +263,17 @@
,@(find-all-features-for-category clause-type *english-grammar-categories*
:features-so-far `((constituents ,clause-subunits)
(parent ,parent))))
;(functional-structure
; (,@(when subject-unit-name
; `((subject ,subject-unit-name)))
; ,@(when object-unit-name
; `((object ,object-unit-name)))
; ,@(when dative-unit-name
; `((dative ,dative-unit-name))))))))
;; The VP and its subunits.
(,vp-unit-name
,@(find-all-features-for-category
'VP *english-grammar-categories*
:features-so-far `((constituents ,verb-unit-names)
(parent ,clause-unit-name)
;(functional-structure
; (,@(when subject-unit-name
; `((subject ,subject-unit-name)))
; ,@(when object-unit-name
; `((object ,object-unit-name)))
; ,@(when dative-unit-name
; `((dative ,dative-unit-name)))))
(head ,(word-dependency-spec-unit-name root-spec))))))
verb-units
;; The functional units.
functional-units)))
;; (comprehend "I see Mickey Mouse")
;; (comprehend "I see Mickey Mouse and Donald Duck.")
(defun nominal-phrase-p (unit)
(find '(phrase-type NP) (unit-feature-value unit 'syn-cat) :test #'unify))
......
......@@ -188,6 +188,36 @@
unless (string= "punct" (rest (assoc :DEPENDENCY dependent)))
collect dependent))
;; dependency-promote-conjuncts
;; -----------------------------------------------------------------------
(export '(dependency-promote-conjuncts))
(defun climb-to-first-conjunct (id dependency-tree)
(dolist (x dependency-tree)
(let ((node-id (rest (assoc :node--id x))))
(when (string= id node-id)
(let ((head-id (format nil "~a" (rest (assoc :head--id x)))))
(if (member (rest (assoc :dependency x)) '("conj" "cc") :test #'string=)
(return (climb-to-first-conjunct head-id dependency-tree))
(return (values (parse-integer head-id) (rest (assoc :node--id x))))))))))
(defun dependency-promote-conjuncts (dependency-tree)
"Treat conjuncts as items on the same level."
(let ((ids-to-be-expanded nil))
(reverse (loop for dependent in (reverse dependency-tree)
collect (cond ((member (rest (assoc :dependency dependent)) '("conj" "cc") :test #'string=)
(let ((old-head-spec (assoc :head--id dependent)))
(multiple-value-bind (the-head the-node)
(climb-to-first-conjunct (format nil "~a" (rest old-head-spec))
dependency-tree)
(pushnew the-node ids-to-be-expanded :test #'string=)
(substitute `(:head--id . ,the-head) old-head-spec dependent :test #'equal))))
((member (rest (assoc :node--id dependent)) ids-to-be-expanded :test #'string=)
(append dependent `(:first-conjunct)))
(t
dependent))))))
;; Compare:
;; --------
;; (preprocess-using-dependency-tree "I saw Barack Obama" :preprocessing-steps (list #'dependency-string-append-named-entities))
......
......@@ -41,7 +41,10 @@
:pos-tag (nlp-tools::dp-get-tag dependency)
:node-id (parse-integer
(nlp-tools::dp-get-node-id dependency))
:head-id (nlp-tools::dp-get-head-id dependency))))
:head-id (nlp-tools::dp-get-head-id dependency)
:conjunct-type (loop for x in dependency
when (eql x :first-conjunct)
return t))))
(defmethod translate-dependency-tree ((base-transient-structure coupled-feature-structure)
(dependency-tree list)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment