如何从python获取成绩单中的演讲者姓名? [英] How get Speaker name from transcript with python?

查看:122
本文介绍了如何从python获取成绩单中的演讲者姓名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写一个程序,可以识别谁是文本中的发言者,他告诉我什么,然后我必须在屏幕上打印演讲者姓名和演讲,如下所示。如果某人(假设Ram)说了些什么,并且在他的演讲中另一个人(假设Sam)说了些什么,那么我必须将它添加到2行中,如:

Ram | < Ram的整个演讲,包括Sam>

Sam | < Speech>

|仅用于显示字符串之间的差异 -

演讲

请参阅以下示例以正确理解。



我有如下文本文件 -



====文本文件的开头====

拉姆说他是个好孩子。

Sam还说我也是一个像Ram一样的好男孩。

Ram问Sam他想去哪里?

Sam回答说他想做点什么但是Naren他的恶魔说他去上学,所以他无法完成工作。



======文本文件的结尾======


我必须在另一个文本文件中这样做 -



======== START文本文件======

Ram| 说| 他是一个好孩子。

Sam| 还说| 我也是像Ram这样的好孩子。

Ram| 问| 山姆,他想去哪里?

Sam| 回复| 他想做点什么,但是Naren他的恶魔说他去上学,所以他不能干活。

Naren| 说| 他去上学

=======文本文件的结尾======

How to write a program which can identify that who is the speaker in a text and what is he telling then I have to print "Speaker Name" and "The speech" on the screen like below. And if someone(assume Ram) says something, and in his speech another one (assume Sam) says something then I have to add it in 2 lines like-
Ram | <Whole Speech of Ram including Sam>
Sam | <Speech>
The " | " just for showing the different between string like-
Speaker | Speech
Please see the example below to properly understand.

I have text file like this below-

==== START OF THE TEXT FILE ====
Ram said that he was a good boy.
Sam also said "I am also a good boy like Ram".
Ram asked Sam that where he wanted to do?
Sam replied that he wanted to do some thing but Naren his fiend said him to go to school, so he could not do the work.

====== END OF THE TEXT FILE ======

I have to make it like this in another text file-

======== START OF THE TEXT FILE ======
"Ram" | "said" | "that he was a good boy."
"Sam" | "also said" | "I am also a good boy like Ram".
"Ram" | "asked" | "Sam that where he wanted to do?"
"Sam" | "replied" | "that he wanted to do some thing but Naren his fiend said him to go to school, so he could not do the work."
"Naren" | "said" | "him to go to school"
======= END OF THE TEXT FILE ======

推荐答案

创建简单的if else then语句并从中创建数组。

这应该是解决学校项目的足够信息
Create simple if else then statements and create array from them.
That should be enough info to solve the school project


这篇关于如何从python获取成绩单中的演讲者姓名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆