如何查找字典并将句子从文件拆分成单词? [英] How to lookup into dictionary and split sentences from file into words?

查看:74
本文介绍了如何查找字典并将句子从文件拆分成单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在处理一个问题,我必须扫描一个文本文件(此文件中有一个或多个句子)并打印出所有单独的单词一句话


我们输入Sentence.txt文件,然后运行Perl程序。它将在字典文件(.txt)中查找然后打印出出现的句子中的单词在字典中


例如:今天是星期六。在字典中查找后,如果单词匹配,Perl将打印出来:今天,是,星期六(每行一行)


I''m dealing with a problem in which I have to scan through a text file (there are one or more sentences in this file) and print out all the separated words in a sentence

We input Sentence.txt file,and run Perl program.It will lookup in a dictionary file (.txt) and then print out the words in sentence(s) which appear in the dictionary

For example: "today is Saturday". After lookup in dictionary, if the words match, Perl will print out: today,is,saturday (each word in one line)

推荐答案

我的第一个请求是将以下两行添加到脚本的开头:

My first request would be that you add the following two lines to the beginning of the script:

展开 | 选择 | Wrap | 行号


^^谢谢杰夫。像往常一样,我总是在代码中加上严格和警告但这一次我''忘了那些东西


在放这些行之前,我在编译代码时没有看到任何错误,但实际上代码没有运行。


现在看来我有很多道具lem与变量和功能decleration

^^ thanks Jeff.As usual,I always put strict and warning in the code but this time i''ve forgot that things

Before putting those lines, i do not see any errors during compiling the code, but actually the code does not run.

Now it seems that i have many proplem with the variable and function decleration


发布代码时,最好使用代码代码而不是发布代码图形图像。


修复这些错误会发生什么,或者你不知道这些错误是什么意思或如何解决它们?
When posting code, it''s best to use the code tags instead of posting a graphic image.

What happens when you fix those errors, or do you not know what those errors mean or how to fix them?


这篇关于如何查找字典并将句子从文件拆分成单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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