QA system - Question Generation

关于如何从给定文本中产生合适的问句。–持续更新中–

做了一段时间的 Asking System,尝试了各种包,也踩了很多的坑,从全无头绪到现在小有心得,中间经历了很多,这里做一些记录。

总的思路是找出简单的陈述句,然后对其进行变形(如下)。

1
2
X is Y => Is X Y? / What is Y? (what/why/who/when)
The X verbs Y => Does X verb Y / What does the X verb?

第一大问题是怎么找候选陈述句,过于复杂的句子我们需要进行简化,我们要找的句型是 S < (NP $.. VP),然而就是这样的 NP VP 下接的诸多介词短语或从句也够我们烦恼的了,定义更加限制性的规则还是很有必要的。另外非常适合用来产生问题的句子结构还有 同位语结构动词修饰名词结构等等,下文会提到。

找出的这些候选陈述句应当提前做好 指代消解,方便进一步处理。

无论是对一般疑问句还是特殊疑问句,关键的都是找 谓词(predicate)

对于一般疑问句而言,如果 predicate 是 auxiliary verb 或者 modal,比如 is, was, are, did, have, etc.,那么直接将 predicate 提前,其余部分按原顺序拼接,而 predicate 不是 auxiliary verb 也不是 modal,那么可能需要将动词还原成 do+动词原形的形式,然后将助动词提前,其余照抄(此时句子中的动词已经还原)。

而对特殊疑问句而言,需要利用 NER 来确定对哪个词进行提问以及用哪种疑问词,NER 的质量在这种场景下显得尤其重要。在实践过程中发现部分的 NER 对时间和地点的识别能力不是很强,这时候可能需要人工规则来进行补充,比如给介词短语添加限制来确定地点等。特殊疑问句另一个问题是一些不可能作为 answer phrase 的词,在下文的 Marking Unmovable Phrases 中也会提到,最为简单粗暴的方法是在 what/who 的问句中只对直接宾语来进行提问。

最后,关于问句的泛化,可以利用 WordNet 来替换一些关键词。

顺便提一下句子类型,在论文里经常会出现 declarative sentence 这类专有名词,这里稍稍解释翻译下。

  • Declarative Sentences
    陈述句,陈述一个事实,以句号结尾,是最常见的类型
    e.g. There are five million people at risk.
  • Imperative Sentence
    祈使句,以感叹号或者句号结尾
    e.g. Fetch my umbrella!/Please bring my umbrella.
  • Interrogative Sentence
    疑问句,以问号结尾
    e.g. Can you find my umbrella?
  • Exclamatory Sentence
    感叹句,表达兴奋或者其他情感,感叹号结尾
    e.g. You’ve broken my umbrella!

在 QG 系统中,我们需要的是 Declarative Sentences

QG Framework

问句如何产生?一般是从文章中提取出合适的可以产生问句的 candidate,然后对其进行变形来得到。很多有用的问题可以被看做是把一个陈述句通过 词汇(lexical)、句法(syntactic)、语义(semantic) 层面的转化得到的。因此,在产生问句的阶段,我们需要把原有的句子转化为陈述句。

看一下 question generation 的框架。
1.jpg

Stage 1,通过改变词汇来将原有语句转化为陈述句。有些句子很复杂,有些句子我们只需要某些成分,所以可以通过一些方法将原有的句子化简,形成能够产生问句的陈述句。在这个阶段,很多 NLP transformation 的方法都会被用到,包括 extractive summarization, sentence compression, sentence splitting, sentence fusion, paraphrase, textual entailment, lexical semantics for word substitution 等。

Stage 2,通过进行一些句法层面的转化(如 WH-movement, subject-auxiliary inversion 等)将陈述句转换为问句,这个模块又叫 question transducer。

Stage 3,对上一阶段产生的问题进行排序,特征可以是 source sentence, input sentences, question, transformation 各部分的特征集合。

明确一些概念:

  • source sentence
    输入文档中的原始句子
  • input sentence
    question transducer 的输入,可能是原始句子也可能是经过转化的陈述句
  • answer phrase
    陈述句里可能被作为问句成分的目标词(targets for WH-movement)
  • question phrase
    替代 answer phrase 的疑问词

Stage 1

Introduction

输入: 原始文本
输出: 陈述句

过于复杂的句子往往会导致不自然或者没有意义的问句,因此我们首先需要进行预处理以便简化 transformation。可以做的比如移除一些短语类型,像是句子开始的连词,句子层次的修饰语等,在论文 headline generation (Dorr and Zajic, 2003) and summarization (Toutanova et al., 2007) 中有具体介绍。一些规则如下

2.jpg

Practice

实际项目中为了得到更快的速度,我们大大简化了这一流程,首先,忽略所有过长的句子(>=50个单词),其次,只选择 同位语(APPOSITION)、动词修饰短语(VERB_MODIFIER)、名词动词结构的短语(NP_VP) 三种类型的句子成分作为产生问句的 candidate。

规则

1
2
3
NP_VP = "S < (NP=np ?$PP=pp1 $.. (VP=vp < (/VB.?/=tensed ?$.. SBAR=reason)))"
APPOSITION = "NP !< CC !< CONJP < (NP=np1 $.. (/,/ $.. (NP=app $.. /,/)))"
VERB_MODIFIER = "NP=noun > NP $.. VP=modifier"

操作这些规则还是用 tregex,由于是 python,选择 Stanford coreNLP,具体见 ParseTree操作若干-Tregex and Stanford CoreNLP

对标注好的部分进行重组,形成规范化的简单句子。以 NP_VP 规则为例,就是形成 NP + VP + PP1的句子。

Stage 2

输入: 上一步产生的陈述句
输出: 一个问句集合

先来看一下流程图,下图描述了如何从给定文本产生一个问句,带*的表示特殊疑问句必须的步骤,一般疑问句不需要。
0.jpg

answer type 可以是名词短语或者是介词短语,能够产生 who, what, where, when, how much 这类的问句。系统可以进行扩展来产生其他的类似 how, why, what kind of 这类的问句。

一个句子可能存在多个可能的 answer phrase,而一个 answer phrase 可能产生多个 question phrase,举个例子

1
2
3
4
5
6
7
8
Declarative sentence:
Francium was discovered by Marguerite Perey in France in 1939
Possible questions:
• Where was francium discovered by Marguerite Perey in 1939?
• When was francium discovered by Marguerite Perey in France?
• Was francium discovered by Marguerite Perey in France in 1939?
• By what was francium discovered in France in 1939?

当然,最后一个句子是一个错误,Marguerite Perey 应该是个人。Question transducer 会 overgenerate 很多不相关、不重要的问句。这一阶段会用到的技术:

  • mark phrases that cannot be answer phrases, due, for example, to island constraints;
  • remove each answer phrase and generate possible question phrases for it;
  • decompose the main verb;
  • invert the subject and auxiliary verb;
  • insert one of the question phrases

一个完整的例子
3.jpg

Marking Unmovable Phrases

input tree 中有些短语由于 WH-movement 的限制,是不可能作为 answer phrases 的,所以我们可以预先把这些成分用 UNMV- 标记给替换掉,这部分的操作可以是并行的,因为它们的顺序不重要。当然这里有两条规则是例外的,它们用在限制 input tree 的下一步传播,适用于所有其他规则,第一条规则把 UNMV- 节点下的所有节点都标记为 UNMV-。第二条规则把 movable 节点下的所有节点标记为 UNMV-,因为名词短语是可以移动的 islands,名词短语是可以移动的这一事实限制很有用,比如说,在关系从句中的短语是不能移动的,如下面产生的问句是不合理的。

1
2
3
4
5
Input sentence:
I bought the book that inspired Bob.
Question:
Who did I buy the book that inspired?

具体规则如下:
4.jpg

Generating Possible Question Phrases

transducer 查看所有可能的 answer phrase,对每一个可能,复制 input tree,移除 answer phrase,产生可能的 question phrase(这个过程在 yes-no 问句中省略)。

给定一个 answer phrase,question phrase 包含一个 question word(e.g., who,what,where,when),也可能是个介词短语如 whose car,跟着 answer phrase 的 head。

对一个给定的 answer phrase,系统使用这个短语的 entity label 和句法结构来产生一系列可能的 question phrase,每一个都用来产生最后的问句。下图描述了产生 question phrase 的一些限制。

5.jpg

Practice

实践中我们用 spacy 来检测 named entity,主要是因为 spacy 的速度很快,

先对所有 word 进行遍历,找到 PRP 或者 NUM,判断是否能形成 whose 以及 how many/how much 的问题,同时记录是否有 named entity,如果有,再来看 named entity

1
2
3
4
if word.tag_.startswith('PRP') and is_possessive(word):
question_phrase = 'whose'
if word.pos_.startswith('NUM') and word.ent_type_ != 'DATE'::
question_phrase = 'how many_how much'

之所以要分两步,是因为上面的 whose 和 how many/how much 其实是对单词提问的,而剩下的 who/where/when/how/why 是对短语进行提问的。对于 who/where/when,可以用 named entity 来进行识别。

1
2
3
4
5
6
if ne.label_ == 'PERSON':
question_phrase = 'who'
if ne.label_ in ['LOC','GPE']:
question_phrase = 'where'
if ne.label_ in ['DATE','TIME']:
question_phrase = 'when'

对于 why 和 how,基本是基于规则,如果在 reason 部分有 because, since, as 等表示原因的单词,那么就可以产生 why 的问句,如果在 pp2 部分有 using, by, through, with, via 等表示方式的单词,就可以产生 how 的问句。

值得注意的是,有些数字后面跟的是速度的单位,比如说 km/s, mph 等,这时候问 how many(much) km/s 就有点诡异了,所以可以加个判断,如果量词后面跟这些单词,就产生 how fast 的问句;另外有些数字后面如果跟的是 %,那么就变成 how many percent 这种问句。至于用 how many 还是 how much,就看下一个名词是单数还是复数了(注意如果量词是 one,下一个名词是单数,然而提问方式得变成 how many noun_plural)。

Decomposition of the Main Verb

Introduction

为了实现 subject-auxiliary inversion,如果一个 auxiliary verb 或者 modal 没有出现,question transducer 将会把主要的动词还原成 do(合适形态) + 动词原形,然后修改动词短语的树的结构。

如 John saw Mary 会变成 John did see Mary。

如果 auxiliary verb 已经存在了,那么并不需要 decomposition,如 John has seen Mary 会变成 Who has John seen。

下图识别了需要 decompose 的动词

6.jpg

另外,可以通过 WordNet 来 lemmatize each verb first by checking morphological variants,每次从动词的最右边去掉一个字母直到在 WordNet 里找到匹配的单词,这种方法非常适合英文因为大多数动词都可以从 lemma 添加几个字母(如 ed)派生得到,或者从 WordNet 里的 lemma 匹配得到。

Practice

这里用到了 patterns.en 的包

1
2
3
4
5
6
7
8
9
10
11
12
from patterns.en import lemma
# check if contains auxiliary
def has_auxiliary(head_verb_tag, verb):
if head_verb_tag=='MD' or lemma(verb[0]) in ['be','do','have'] and len(verb)>1:
return True
return False
# decomposition of verb
def decompose_verb(verb, verb_tag):
tense = verb_tense_dict[verb_tag]
return conjugate('do', tense), lemma(verb)

Subject-Auxiliary Inversion

这一部分仍然是对句子的操作,目的是把陈述句变成问句。

首先,parse tree 的 “S” 需要被重新标记为“SQ”,表示它是问题的一部分。然后移动 auxiliary 或 copula 移动,使它成为 SQ 节点的第一个 child。然后使用 “SQ” 节点为该句子形成一个新树。在 yes-no questions 的情况下,问题树的根节点将具有 “SQ” 节点作为该树唯一的 child。在 WH-questions 的情况下,根节点具有 “SBARQ” 子节点。然后,该 “SBARQ” 节点具有一个问题短语节点(例如“WHNP”) 以及一个 “SQ” 作为子节点。

在转换成问句后,在这个节点和逗号之前的所有修饰语都会被移动到句子的前面,以便产生更自然的问题,如产生 Following Thomas Jefferson, who was elected the 4th president? 而不是 Who, following Thomas Jefferson, was elected the 4th president?

Inserting Question Phrases

将每个可能的 question phrase 插入作为 SBARQ 的子节点,如果是一般疑问句,就不用进行这一步了。

Post-processing

为了保证正确的 formatting and punctuation。句号要改为问号,输出要 detokenized,移除多余的空格。另外,所有包含了代词(pronouns)的问句都太模糊了(e.g., What does it have as a head of state),所以可以过滤掉所有有人称代词(personal pronouns),所属代词(possessive pronouns),以及只包含了限定词(determiners)的名词短语。

当然,改进的版本是进行指代消解。

Stage 3

Discriminative reranker

7.jpg

上图描述了 bad question 出现的一些原因。在产生一大堆可能的问题后,我们要对问句进行排序。论文提到的是用 logistic regression 来定义一个 acceptable probability p(a|q,t) 和 unacceptable probability p(u|q,t) = 1-p(a|q,t)。先训练一个 boolean model ,只要出现上面的任何一种问题,就认为这个问句是 unacceptable 的。接着训练一个 aggregate model,模型如下

$$p(a|q,t)=\prod^K_{i=1}p_i(a_i|q,t)$$

其中 i 是影响 acceptable 的各个因素(grammaticality, making sense, vagueness, etc.), K 在这里是 8。

用到的特征如下图,目标函数是 regularized log-likelihood,regularizaiton constant 由 cross-validation 选择产生。用到的训练集有 WIKI-ENG,WIKI-SIMP 和 theWall Street Journal data in the Penn Treebank

(Marcus et al., 1993)。实验结果表明,aggregate ranking 在 P@10 上提升了 43.3%,在 P@25 上提升了40%。

8.jpg

Practice

实际中我们并没有来训练模型,主要是因为找不到合适的有标注的训练集。我们用了非常简单的几个标准来进行排序。

  • Complexity
    看 question 包含了多少个单词
    划分4 个 bucket [0, 5], [5, 20], [20, 30], [30,…],如果在 [5,20] 之间,给最高分,在 [0, 5] 或者 [30,…] 间,就给 penalty
  • Difficulty
    基本假设是一个好的问题应该有一个确定的答案与之相配。理想情况下是看这个问句能不能被回答,以及容不容易被回答。
    然而这里的答案抽取、问题产生大部分依赖规则,所以也用规则来定义问题难度了,认为 what, why, how 比较难回答, question word 在中间的句子比较难回答,这些规则通过观察部分有标签的数据集得到
  • Diversity
    给每种类型的问句设置权重,在结果集里各类问句都按比例出现,保证多样性
  • Fluency
    用 ginger server 来检查语法

Yes/No Question

举个例子说明 binary question
例句1 (包含 auxiliary verb 或者 modal):

1
The cat had/MD slept/VBD on the mat.

我们需要做的是将 MD 前置,拼接句子,将句尾符号变为问号,成为答案是 YES 的问句。

1
2
3
=> Had the cat slept on the mat?
Yes!

例句2 (不包含 auxiliary verb 或者 modal):

1
The cat slept/VBD on the mat.

我们需要做的是 decompose verb,把 slept 变成 did sleep,然后将 did 前置,拼接句子,将句尾符号变为问号,成为答案是 YES 的问句。

1
2
3
=> Did the cat slept on the mat?
Yes!

怎么产生答案是 NO 的句子?

将句子中的 head word 随机替换成同等词性的词。

1
2
3
=> Had the dog slept on the mat?
No!

WH Question

Detect Candidate Sentences and Mark Movable Phrases

1
2
3
4
- Input:
In 2008, because Olympics is coming, 5 valuable pandas including Jingjing were born in Beijing, China.
- Rule:
S < (NP=np ?$PP=pp1 $.. (VP=vp < (/VB.?/=tensed ?$.. SBAR=reason)))
9.jpg

Yes-no Questions

1
2
3
4
- Yes Question:
Were 5 valuable pandas including Jingjing born in Beijing , China in 2008?
- No Question:
Were the swallows born in Beijing , China in 2008?

Choose Answer Phrases and Generate Question Phrases

10.jpg

Decompose Verb

1
2
3
4
Eg.1. In 2008, because Olympics is coming, 5 valuable pandas including Jingjing were born in Beijing, China.
were => were
Eg.2. All four allies retained shared responsibility for Berlin.
retained => did retain

Invert Subject and Auxiliary and Insert Question Phrase

1
2
3
4
5
6
7
8
9
- Input:
5 valuable pandas including Jingjing were born in Beijing, China.
- Output:
were 5 valuable pandas including jingjing born in Beijing , China in 2008
were 5 valuable pandas including jingjing born in Beijing , China in 2008
where were 5 valuable pandas including Jingjing born in 2008
when were 5 valuable pandas including Jingjing born in Beijing , China
how many valuable pandas including Jingjing were born in Beijing , China in 2008
what were born in Beijing , China in 2008

Post Processing

1
2
3
4
5
6
7
8
9
- Input:
5 valuable pandas including Jingjing were born in Beijing, China.
- Output:
Where were 5 valuable pandas including Jingjing born in 2008?
Were 5 valuable pandas including jingjing born in Beijing , China in 2008?
When were 5 valuable pandas including Jingjing born in Beijing , China?
How many valuable pandas including Jingjing were born in Beijing , China in 2008?
What were born in Beijing , China in 2008?
Were 5 valuable pandas including Jingjing born in Beijing , China in 2008?

Tools/Packages

  • python==2.7
  • spaCy==1.7.5
  • pattern==2.6
  • textblob==0.12.0
  • nltk==3.2.2
  • requests==2.13.0
  • scipy==0.18.1
  • sklearn==0.18.1
  • numpy==1.11.3
  • stanford-corenlp-full-2016-10-31

历程

第一阶段

  • 只寻找 NP VP 结构,用的 pattern 为 S < (NP=np $.. (VP=vp < /VB.?/=tensed))
  • 主语为代词(PROP)跳过,不做指代消解(速度慢)
  • NER 考虑了 PERSON, LOC, GPE
  • 对每个句子产生 yes/no 问句,包含 NER 的产生对应的 WHAT/WHO/WHERE 问句

原文(PART)

Ant

Ants are social insects of the family Formicidae ( ), and along with the related wasps and bees, they belong to the order Hymenoptera. Ants evolved from wasp-like ancestors in the mid-Cretaceous period between 110 and 130 million years ago and diversified after the rise of flowering plants. Today, more than 12,500 species are classified with upper estimates of about 22,000 species. They are easily identified by their elbowed antennae and a distinctive node-like structure that forms a slender waist.

Ants form colonies that range in size from a few dozen predatory individuals living in small natural cavities to highly organised colonies which may occupy large territories and consist of millions of individuals. These larger colonies consist mostly of sterile wingless females forming castes of “workers”, “soldiers”, or other specialised groups. Nearly all ant colonies also have some fertile males called “drones” and one or more fertile females called “queens”. The colonies are sometimes described as superorganisms because the ants appear to operate as a unified entity, collectively working together to support the colony.

产生问句

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
NP VP(aux) Are ants social insects of the family Formicidae -LRB- -RRB-
WHO NP VP Who are ants
WHAT NP VP What are ants
NP VP(aux) Are more than 12,500 species classified with upper estimates of about 22,000 species
WHAT NP VP(aux) What are more than 12,500 species
NP VP(no-aux) Do ants form colonies that range in size from a few dozen predatory individuals living in small natural cavities to highly organised colonies which may occupy large territories and consist of millions of individuals
WHAT NP VP(aux) What do ants form
NP VP(no-aux) Do these larger colonies consist mostly of sterile wingless females forming castes of `` workers '' , `` soldiers '' , or other specialised groups
WHAT NP VP(aux) What do these larger colonies consist
NP VP(no-aux) Did males call `` drones '' and one
WHAT NP VP(aux) What did males call
NP VP(aux) Have nearly all ant colonies some fertile males called `` drones '' and one or more fertile females called `` queens ''
WHAT NP VP(aux) What did nearly all ant colonies some
NP VP(no-aux) Do the ants appear to operate as a unified entity , collectively working together to support the colony
WHAT NP VP(aux) What do the ants appear
NP VP(aux) Are the colonies sometimes described as superorganisms because the ants appear to operate as a unified entity , collectively working together to support the colony
WHAT NP VP(aux) What are the colonies
NP VP(aux) Have ants colonised almost every landmass on Earth
WHERE NP VP(aux) Where did ants colonise colonised
NP VP(aux) Are the only places lacking indigenous ants Antarctica and certain remote or inhospitable islands
WHERE NP VP(aux) Where are the only places lacking indigenous ants are
NP VP(aux) Has their long co-evolution with other species led to mimetic , commensal , parasitic , and mutualistic relationships
WHAT NP VP(aux) What did their long co-evolution with other species lead
NP VP(aux) Have hlldobler & Wilson -LRB- 1990 -RRB- , p. 471 Ant societies division of labour , communication between individuals , and an ability to solve complex problems
WHAT NP VP(aux) What did hlldobler & Wilson -LRB- 1990 -RRB- , p. 471 Ant societies division
NP VP(aux) Have these parallels with human societies long been an inspiration and subject of study
WHAT NP VP(aux) What did these parallels with human societies long
NP VP(no-aux) Do many human cultures make use of ants in cuisine , medication and rituals
WHAT NP VP(aux) What do many human cultures make
NP VP(aux) Are some species valued in their role as biological pest control agents
WHAT NP VP(aux) What are some species
NP VP(aux) Is the word ant derived from ante of Middle English which is derived from mette of Old English and is related to the Old High German meiza , hence the modern German Ameise
WHERE NP VP(aux) Where is the word ant derived is derived is related
WHO NP VP Who is the word ant
WHAT NP VP What is the word ant
NP VP(aux) Was the original meaning of the word `` the biter '' -LRB- from Proto-Germanic * ai - , `` off , away '' + * mait - `` cut '' -RRB-
WHAT NP VP(aux) What was the original meaning of the word
NP VP(no-aux) Do all of these words come from West Germanic * amaitjo
WHERE NP VP(aux) Where do all of these words come
NP VP(aux) Are the words in other Romance languages such as the Portuguese formiga , Italian formica , Spanish hormiga , Romanian furnic and French fourmi derived
WHAT NP VP(aux) What are the words in other Romance languages such as the Portuguese formiga , Italian formica , Spanish hormiga , Romanian furnic and French fourmi
NP VP(aux) Is the family name Formicidae derived from the Latin formca -LRB- `` ant '' -RRB- from which the words in other Romance languages such as the Portuguese formiga , Italian formica , Spanish hormiga , Romanian furnic and French fourmi are derived
WHAT NP VP(aux) What is the family name Formicidae
NP VP(no-aux) Does formicidae belong to the order Hymenoptera , which also includes sawflies , bees and wasps
WHAT NP VP(aux) What does formicidae belong
NP VP(no-aux) Did ants fossilise in Baltic amber The family Formicidae belongs to the order Hymenoptera , which also includes sawflies , bees and wasps
WHO NP VP Who did ants fossilise
WHAT NP VP What did ants fossilise
NP VP(no-aux) Did ants evolve from a lineage within the vespoid wasps
WHAT NP VP(aux) What did ants evolve

第一个问题是指代消解,如下面这个句子

1
2
3
4
5
6
Ants are social insects of the family Formicidae ( ), and along with the related wasps and bees, they belong to the order Hymenoptera.
Is supposed to generate
=>
NP VP(no-aux)Do ants belong to the order Hymenoptera
WH NP VP(no-aux)What do ants belong to

应该同时能产生这两个问题,然而现在的代码遇到代词直接跳过,并没有进行匹配,所以不能产生。可以用 standford parser 做一次指代消解,然而再请求一次,加上标注、parse,时间上耗费太久。所以现在想着把上一步的 np 存到一个 list 里,如果下一个 np 匹配找到的是 PRP,就用 np 里的替换。这个解决方案也可以为产生 yes-no question 的 no question 做准备。

第二个问题是介词造成的不完整句子,需要对介词进行进一步处理

1
What does ants consist => What does ants consist of

第三个问题是关于 have,have 可以作为完成时的 auxiliary,也可以作为行为动词 ‘have’ 表示拥有,而这里我默认了 have 作为 auxiliary 出现,其实是不对的,需要分情况讨论

1
2
3
4
5
Have nearly all ant colonies some fertile males called `` drones '' and one or more fertile females called `` queens ''
is supposed to be
=>
Do nearly all ant colonies have some fertile males called `` drones '' and one or more fertile females called `` queens ''

类似的问题是 be,比如 ‘A is B’ 和 ‘A is described as B’ 应该区分对待。

1
2
3
4
5
6
7
NP VP(aux) Are the colonies sometimes described as superorganisms because the ants appear to operate as a unified entity , collectively working together to support the colony ?
=>
WHAT NP VP What are the colonies ?
is supposed to be
=>
What are the colonies described as ?

然而这里有一个难点是 ‘A is described as B’ 和 ‘A is valued ‘

第四个问题是疑问词,因为只 handle 了 WHO, WHAT, WHERE 的问题,而实际上,一些问句应该是 WHEN 的问题,如下。现在想到的是对于包含介词短语的句子,同时产生 WHERE 和 WHEN 两种问句类型,同样的,对于之前产生 WHO 的句子,也产生一个 WHAT 版本,然后由 QUESTION RANKING 来排序筛选。

关于 WHEN,尽量用命名实体 TIME 以及正则规则匹配,准确率会更高一些。

1
2
3
4
Ants evolved from wasp-like ancestors in the mid-Cretaceous period between 110 and 130 million years ago and diversified after the rise of flowering plants.
=> What did ants diversify
Supposed to be
=> When did ants diversify

最后还有一些特殊符号的匹配,可以通过 post-processing 做处理

1
2
-LRB- -RRB- => ()
`` => "

第二阶段

基本解决了第一阶段的问题,并加了 ranking。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Do ants form colonies that range in size from a few dozen predatory individuals living in small natural cavities to highly organised colonies which may occupy large territories and consist of millions of individuals ?
More than 12,500 species are classified with upper estimates of about how many species ?
What do ants form that range in size from a few dozen predatory individuals living in small natural cavities to highly organised colonies which may occupy large territories and consist of millions of individuals ?
What have some fertile males called drones and one or more fertile females called queens ?
Do males appear to operate as a unified entity , collectively working together to support the colony ?
How many species are more than 12,500 species classified with ?
What are classified with upper estimates of about 22,000 species ?
Are ants social insects of the family Formicidae ?
What do these larger colonies consist forming castes of workers , soldiers , or other specialised groups ?
Are more than 12,500 species classified with upper estimates of about 22,000 species ?
Do more than 12,500 species consist mostly of sterile wingless females forming castes of workers , soldiers , or other specialised groups ?
Do these larger colonies consist mostly of sterile wingless females forming castes of workers , soldiers , or other specialised groups ?
What did males call and one ?
What form colonies that range in size from a few dozen predatory individuals living in small natural cavities to highly organised colonies which may occupy large territories and consist of millions of individuals ?
Are people classified with upper estimates of about 22,000 species ?
Do people have some fertile males called drones and one or more fertile females called queens ?
What do the ants appear , collectively working together to support the colony ?
Do the ants appear to operate as a unified entity , collectively working together to support the colony ?
What do nearly all ant colonies have called drones and one or more fertile females called queens ?
Do nearly all ant colonies have some fertile males called drones and one or more fertile females called queens ?
Are nearly all ant colonies sometimes described as superorganisms because the ants appear to operate as a unified entity , collectively working together to support the colony ?
How many species are classified with upper estimates of about 22,000 species ?
Did males call drones and one ?
What are ants of the family Formicidae ?
Are people social insects of the family Formicidae ?
What are more than 12,500 species classified with of about 22,000 species ?
What are the colonies because the ants appear to operate as a unified entity , collectively working together to support the colony ?
What appear to operate as a unified entity , collectively working together to support the colony ?
What called drones and one ?
What are social insects of the family Formicidae ?
What are sometimes described as superorganisms because the ants appear to operate as a unified entity , collectively working together to support the colony ?
What consist mostly of sterile wingless females forming castes of workers , soldiers , or other specialised groups ?
Are the colonies sometimes described as superorganisms because the ants appear to operate as a unified entity , collectively working together to support the colony ?

参考链接:
Question Generation via Overgenerating Transformations and Ranking

徐阿衡 wechat
欢迎关注:徐阿衡的微信公众号
客官,打个赏呗~