public GraphPoet(File corpus) throws IOException {
try {
File file = new File("assets/test.txt");
Scanner scanner = new Scanner(corpus);
scanner.useDelimiter("\\s+");
String preWord = null;
String thisWord;
int i=0;
while (scanner.hasNext()) {
thisWord = scanner.next();
graph.add(thisWord.toLowerCase());
if(i>0){
int lastEdgeWeight = this.graph.set(preWord.toLowerCase(), thisWord.toLowerCase(), 1);
if (lastEdgeWeight != 0)
this.graph.set(preWord.toLowerCase(), thisWord.toLowerCase(), lastEdgeWeight + 1);
}
i=1;
preWord=thisWord;
System.out.println();
}
scanner.close();
} catch (Exception e) {
throw new IOException("File Not Readable or Not Found");
}
public GraphPoet(File corpus) throws IOException {
try{
BufferedReader reader=new BufferedReader(new FileReader(corpus));
BufferedReader bReader = new BufferedReader(reader);
String line;
List<String> words=new ArrayList<>();
while ((line = bReader.readLine()) != null) {
words.clear();
words.addAll(Arrays.asList(line.split("\\s+")));
int num=words.size();
for(int i=0;i<num;i++){
graph.add(words.get(i).toLowerCase());
if(i>0){
int lastEdgeWeight = this.graph.set(words.get(i-1).toLowerCase(), words.get(i).toLowerCase(), 1);
if (lastEdgeWeight != 0)
this.graph.set(words.get(i-1).toLowerCase(), words.get(i).toLowerCase(), lastEdgeWeight + 1);
}
}
}
bReader.close();
checkRep();
}catch (Exception e){
throw new IOException("File Not Readable or Not Found");
}
}
```