Melina
Melina

Reputation: 303

Conjuncts are not identified completely in spaCy?

I want to identify all the conjuncts by using .conjuncts in spaCy dependency parsing.

But, I found a problem that: not all conjuncts are identified.

For example, in the following sentence template:

A....B....C.... D....

If A and D have conj dependency relation; C and D also have a conj relation. But, A has no conj relation with B and C; D has no conj relation with B and C.

In this case, the conj relation between C and D can be shown in the graphical dependency relation by using .displacy, BUT, while using the .conjuncts to list all conjunct pairs (chunk and conjunct), the conjunct (tuple) of C is empty (), the conjunct (tuple) of D is empty ().

Code for getting the conjuncts:

prev_end=0
for chunk in doc.noun_chunks:
    span = doc[prev_end: chunk.end]
    conj_ = span.conjuncts
    prev_end = chunk.end 

--Does anyone know the reason?

--Is it because of the bug in the spaCy library or anything else?

Thanks in advance!

Upvotes: 0

Views: 160

Answers (1)

polm23
polm23

Reputation: 15593

This was answered in detail on the forum, but the issue here is that you aren't using the noun chunks, you're using divisions of the sentence that include noun chunks.

When you call .conjuncts on a span, you get the conjuncts of the span root. In a noun chunk the head noun is the root, but with your spans sometimes verbs are included, so the conjuncts could be conjuncts of that verb, not the noun chunk's head.

Upvotes: 1

Related Questions