Skip to content

Commit

Permalink
Break down method goal into small pieces for code simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanDeboutGat committed Apr 5, 2021
1 parent 971ca5b commit 19fa585
Showing 1 changed file with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,21 @@ public String select(String html) {
text.setLength(0);

for (int i = 0; i < indexDistribution.size() - 1; i++) {
if (indexDistribution.get(i) > threshold && ! boolstart) {
if (indexDistribution.get(i+1).intValue() != 0
|| indexDistribution.get(i+2).intValue() != 0
|| indexDistribution.get(i+3).intValue() != 0) {
if (indexDistribution.get(i) > threshold && ! boolstart
&& !isAnyIndexDistributionZero(indexDistribution,i+1,i+2,i+3)){
boolstart = true;
start = i;
continue;
}
}
if (boolstart) {
if (indexDistribution.get(i).intValue() == 0
|| indexDistribution.get(i+1).intValue() == 0) {
if (boolstart && isAnyIndexDistributionZero (indexDistribution,i,i+1)) {

end = i;
boolend = true;
}

}


StringBuilder tmp = new StringBuilder();
if (boolend) {
//System.out.println(start+1 + "\t\t" + end+1);
Expand All @@ -83,9 +82,27 @@ public String select(String html) {
}
return text.toString();
}



@Override
public List<String> selectList(String text) {
throw new UnsupportedOperationException();
}

private static boolean isAnyIndexDistributionZero( ArrayList <Integer> indexDistribution, int index, int successorIndex, int afterSuccessorIndex = null) {


if (afterSuccessorIndex != null) {
return (indexDistribution.get(index).intValue() == 0
&& indexDistribution.get(indexSuccessor).intValue() == 0
&& indexDistribution.get(afterSuccessorIndex).intValue() == 0 );
}else {
return (indexDistribution.get(index).intValue() == 0
|| indexDistribution.get(indexSuccessor).intValue() == 0);
}

}



}

0 comments on commit 19fa585

Please sign in to comment.