Determining the question type

The relationships detected suggest ways to detect different types of questions. For example, to determine whether it is a who type question, we can check whether the relationship is a nominal subject and that the governor is who.

In the following code, we iterate over the question type dependencies to determine whether it matches this combination, and if so, call the processWhoQuestion method to process the question:

for (TypedDependency dependency : tdl) { 
    if ("nominal subject".equals( dependency.reln().getLongName()) 
        && "who".equalsIgnoreCase( dependency.gov().originalText())) { 
        processWhoQuestion(tdl); 
    } 
} 

This simple distinction worked reasonably well. It will correctly identify all of the following variations to the same question:

    Who is the 32nd president of the United States?
    Who was the 32nd president of the United States?
    The 32nd president of the United States was who?
    The 32nd president is who of the United States?
  

We can also determine other question types using different selection criteria. The following questions typify other question types:

    What was the 3rd President's party?
    When was the 12th president inaugurated?
    Where is the 30th president's home town?
  

We can determine the question type using the relations that are suggested in the following table:

Question type

Relation

Governor

Dependent

What

Nominal subject

What

NA

When

Adverbial modifier

NA

When

Where

Adverbial modifier

NA

Where

 

This approach does require hardcoding relationships.createPresidentList.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset