Skip to content
Snippets Groups Projects

Develop

5 files
+ 28
25
Compare changes
  • Side-by-side
  • Inline

Files

@@ -61,11 +61,13 @@ public class SpaCy {
ArrayList<ArrayList<Integer>> array = new ArrayList<>();
try {
while ((line = reader.readLine()) != null) {
String[] str = line.split(" ");
ArrayList<Integer> list = new ArrayList<>();
list.add(Integer.parseInt(str[0]));
list.add(Integer.parseInt(str[1]));
array.add(list);
if (!line.equals("")) {
String[] str = line.split(" ");
ArrayList<Integer> list = new ArrayList<>();
list.add(Integer.parseInt(str[0]));
list.add(Integer.parseInt(str[1]));
array.add(list);
}
}
} catch (IOException e) {
System.out.println("The text file contains incorrect data." + e.getMessage());
@@ -74,14 +76,14 @@ public class SpaCy {
}
/**Checks if input sentence is from a different language.*/
public boolean isForeignSentence(String inputString, int matchFrom) {
public boolean isForeignSentence(String inputString, int idx, int matchFrom) {
boolean isForeginSent = false;
if (loaded) {
for (List<Integer> tuple : foreignSentenceArray) {
if (matchFrom >= tuple.get(0) && matchFrom < tuple.get(1)) {
return Character.isUpperCase(inputString.charAt(matchFrom));
if (matchFrom >= (tuple.get(0) - idx) && matchFrom < (tuple.get(1) - idx)) {
return true;
}
if (matchFrom > tuple.get(1)) {
if ((tuple.get(1) - idx) > matchFrom) {
return false;
}
}
@@ -90,7 +92,7 @@ public class SpaCy {
}
/**Checks if input sentence is from a proper noun.*/
public boolean isProperNoun(String inputString, int matchFrom) {
public boolean isProperNoun(String inputString, int idx, int matchFrom) {
boolean isProperNoun = false;
if (!loaded) {
if (Character.isUpperCase(inputString.charAt(matchFrom))) {
@@ -107,10 +109,10 @@ public class SpaCy {
}
} else {
for (List<Integer> tuple : properNounArray) {
if (matchFrom >= tuple.get(0) && matchFrom < tuple.get(1)) {
if (matchFrom >= (tuple.get(0) - idx) && matchFrom < (tuple.get(1) - idx)) {
return Character.isUpperCase(inputString.charAt(matchFrom));
}
if (matchFrom > tuple.get(1)) {
if ((tuple.get(1) - idx) > matchFrom) {
return false;
}
}
Loading