1

Given a POS (part of speech), tag, and dependency for words, where can I find words that have the same POS, tag, and dependency?

I only need a list of words by (pos,tag) and do not need code for this (I am only interested in the pos and tag that spaCy outputs). For example:

(VERB, VBG): ["being", "having", "going", "getting", "doing"]
(AUX, VBZ): [...]
...
(NOUN, NN): ["cat", "house", "computer", "stack", "head"]

I know there are a few examples at Universal Dependencies, for example, in the case of example 1, it suggests ["being", "having", "going", "getting", "doing"].

Example 1

Input:

  • Sentence: He is shaving his head.
  • Word: 3 (shaving)
    • POS: VERB
    • Tag: VBG
    • Dependency: ROOT

Processing by spaCy (shown for context):

import spacy

nlp = spacy.load("en_core_web_sm")
doc = nlp("He is shaving his head.")

for token in doc:
    print(token.text, token.lemma_, token.pos_, token.tag_, token.dep_,
            token.shape_, token.is_alpha, token.is_stop)

"""
Code output
Text    Lemma  POS   tag  dep   shape isAlpha isStopWord
He      he     PRON  PRP  nsubj Xx    True    True
is      be     AUX   VBZ  aux   xx    True    True
shaving shave  VERB  VBG  ROOT  xxxx  True    False
his     his    PRON  PRP$ poss  xxx   True    True
head    head   NOUN  NN   dobj  xxxx  True    False
.       .      PUNCT .    punct .     False   False
"""

Output:

  • Alternatives: ["working", "cleaning", "building"]
    • He is working his head.
    • He is cleaning his head.
    • He is building his head. might not make sense in context, but this is acceptable.

Example 2

Input:

  • Sentence: He is shaving his head.
  • Word: 1 (He)

Output:

  • Alternatives: ["Uncle", "She", "Maria"]
    • Uncle is shaving his head.
    • She is shaving his head.
    • Maria is shaving his head.
2
  • Yes, I think this is a general question of methodology whereas the specific programming implementation is a bit flexible. You have a word with certain tags. Now you want to find other words with the same tags. Where will the words come from? That's quite flexible. You can use a corpus (NLTK has corpora). You can just upload textual data, if you want - how about some ebooks from Gutenberg, or Wikipedia articles? Or you can write a program that gathers text from webpages. Or maybe find dictionary-type data. All you must do is perform the same Spacy annotation and then search for words matching Jan 13, 2023 at 9:37
  • that annotation. I can try to supply some specific code for that a little later. Thank you. Jan 13, 2023 at 9:37

1 Answer 1

1

Your question is somewhat unclear, but for getting a list of words having the same (pos,tag,dep) values you need a corpus where all these exist as annotations. Than you can query the corpus and get words fitting the query, e.g., using CQP as query language

[pos="VERB" & tag="VBG" & rel="ROOT"]

returns all -ing forms of verbs that are sentence roots.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.