我目前正在做一个算法项目,在这里我们必须使用两个文本文件来填写缺少单词的空格。其中一个txt文件包含名为“ The Truman Show”的电影的完整脚本,而另一个txt文件包含带有“ ”指示的单词缺失的句子(语句)。我发现了单词缺失来自Script.txt,我知道该怎么做,我应该使用replaceAll用特定的单词替换' 。
我正在使用BufferedReader扫描两个txt文件,并且一个缓冲的阅读器都有一个指针i,另一个缓冲的阅读器都有一个指针j。 我停在丢失单词的开头,我应该如何使用指针j获得丢失单词。
while(i < Movie_Script_Length)
{
if(Current_Statement.charAt(j) == Movie_Script.charAt(i))
{
i++;
j++;
}
else if(Current_Statement.charAt(j) != Movie_Script.charAt(i) && Current_Statement.charAt(j) == Underscore)
{
//Replace the underscores with the word
Current_Statement.replaceAll(regex,replacement);
//System.out.println("Missing word found for Statement " + Statement_Number);
}