如何从Stanford NLP输出(JSON/XML)识别指定动作动词?
Absolutely! You can absolutely pull the specific action verbs you want (like assigns and make in your example, excluding tries) from Stanford CoreNLP's JSON or XML results. The key is to combine part-of-speech (POS) tagging with dependency parsing to distinguish between "action verbs" and verbs that express intention/attempt (like tries).
Step 1: Understand the Role of Each Verb in Your Sentence
Looking at your parsed tree, let’s break down each verb’s syntactic role:
assigns(VBZ): This is the core action verb of the subordinate clause ("when a teacher assigns a project"). It’s an independent, concrete action with no higher-level intention verb governing it—so it’s a keeper.tries(VBZ): This is the root verb of the main clause, but it only expresses the student’s attempt to perform an action. The actual concrete action happens in its complement clause—so we exclude it.make(VB): This is the core verb of the infinitive complement (to make it) attached totries. It’s the concrete action the student is attempting, so it’s a keeper.
Step 2: Extract & Filter from JSON/XML Output
Stanford CoreNLP’s JSON/XML output includes both POS tags and dependency relationships, which we’ll use to filter:
First: Filter for Verbs via POS Tags
First, pull all tokens with verb POS tags. These include:
VB(base form verb, e.g.,make)VBZ(3rd person singular present, e.g.,assigns,tries)- Other verb tags like
VBD(past tense),VBG(gerund),VBN(past participle),VBP(plural present)
Second: Filter Out Intention/Attempt Verbs via Dependency Parsing
Next, use dependency labels to exclude verbs that act as "intention holders" (like tries):
- Look for verbs that are marked as the
ROOTof the main clause, and have anxcomp(open clausal complement) dependency pointing to another verb. These verbs (liketries) are typically intention/attempt verbs that don’t represent the concrete action you want. - Alternatively, maintain a small list of common intention/attempt verbs (e.g.,
try,want,plan,intend,attempt) and exclude any lemma matching these terms.
Example JSON Logic
In CoreNLP’s JSON output, each token will have fields like pos, dep (dependency label), governor, and lemma. For your sentence:
- The token for
assignswill havepos: "VBZ"anddep: "ROOT"(of its subordinate clause) → keep it. - The token for
trieswill havepos: "VBZ",dep: "ROOT"(main clause), and will have a dependent token (make) withdep: "xcomp"→ exclude it. - The token for
makewill havepos: "VB"anddep: "xcomp"→ keep it.
Final Note
This approach works reliably because it combines syntactic structure (dependency parsing) with basic POS filtering to target exactly the concrete action verbs you need, while excluding verbs that only express intention or attempt.
内容的提问来源于stack exchange,提问作者bearami

