0

用户填写表格。使用表单中的文本,程序会自动生成句子。

例如:

[enter name], 一[student/professor],在他的研究中[enter name of university]获得了奖项; 该奖项是在in颁发的。来自世界各地的著名科学家出席了会议。[enter award][name of topic][name of conference][name of country]

生成的文本将变为:

马来西亚国家石油大学学生Muhammad Afiq在石油管道路线研究方面获得卓越奖;该奖项是在马来西亚绿色技术会议上颁发的。来自世界各地的著名科学家出席了会议。

你知道我可以使用哪种技术或语言来学习如何做到这一点吗?我是一名记者。所以我正在寻找一种方法来设计一个简单的程序,让我能够在我不想写的时候填写表格。

我知道一些 Python,但我无法使用它来创建这个程序。到目前为止,我所有的搜索(包括在这个网站上)都返回了 NLP 和 AI 的结果——这不是我想要的。也许我使用了错误的搜索词?

请您指点我一个可以学习如何做到这一点的地方,或者在某个地方有一个模块吗?

谢谢。

编辑:

我用 Python 试过这个:

full_name =input("enter name")
occupation =input("enter occupation")
name_of_university =input("enter name of university")
award= input("enter award received")
topic=input("enter topic")
conference =input("enter name of conference")
country =input("enter name of country")
display_concatenation =   full_name+occupation+name_of_university+award+topic+conference+country
print (display_concatenation)

它没有用。

4

2 回答 2

0

If I understand your idea, shouldn't it be like this?

name = raw_input("Your name")
student_proff = raw_input("Student/proffessor")
s = "[enter name], a [student/professor] of [enter name of university], received the award of [enter award] in his research on [name of topic]; the award was given at the [name of conference] in [name of country]. The conference was attended by eminent scientists from all over the world."
print s
s = s.replace("[enter name]", name).replace("[student/professor]", student_proff)
print s

UPDATED: Added working example :)

于 2012-04-26T11:15:09.897 回答
0

我相信几乎所有语言都支持字符串。因此,假设名称位于“fullName”字段中,您将开始构建字符串

string sentence = fullName.Value() + ", a " + .. 

http://www.w3schools.com/是一个不错的网站,您可以从这里开始。Java、.NET、Python、Ruby 都会这样做,这只是个人选择

于 2012-04-26T10:28:03.367 回答