3
我無法從文件中讀取一行,然後將其分解爲單個單詞。假設我讀過「當夜幕降臨時」,因爲那是第一行,我無法弄清楚如何讓「剩餘時間」這個詞消失,我已經嘗試過多次,已經沒有想法了。對於Ada中的無界字符串以及一般的Ada,我是相當新的。任何幫助表示讚賞,小提示或解決我的問題,謝謝。如何從無界字符串中獲取較小的字符串
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
with AVL; use AVL;
procedure Spellchecker is
InWord : Unbounded_String;
ReadIn : String (1..20);
Break : Character := ' ';
RevisedWord : String(1..20);
Dictionary : File_Type;
Paragraph : File_Type;
Count : Integer;
LastChar : Integer;
NewTree : Tree;
type Spell is array (Integer range 1..20) of Character;
Revision : Spell;
begin
Ada.Text_IO.Open (File => Dictionary,
Mode => In_File,
Name => "dictionary.txt");
loop
exit when End_of_File (File => Dictionary);
InWord := Get_Line (File => Dictionary);
Insert (InWord, NewTree);
end loop;
Close (File => Dictionary);
Print (NewTree);
InWord := Get_Line (File => Paragraph);
Count := 1;
Put (InWord);
end Spellchecker;
您可能會發現[此答案](http://stackoverflow.com/a/22857680/40851)有幫助。我知道它使用了一個GNAT特定的庫,但它分裂了。 –