@@ -51,22 +51,21 @@ public String select(String html) {
51
51
text .setLength (0 );
52
52
53
53
for (int i = 0 ; i < indexDistribution .size () - 1 ; i ++) {
54
- if (indexDistribution .get (i ) > threshold && ! boolstart ) {
55
- if (indexDistribution .get (i +1 ).intValue () != 0
56
- || indexDistribution .get (i +2 ).intValue () != 0
57
- || indexDistribution .get (i +3 ).intValue () != 0 ) {
54
+ if (indexDistribution .get (i ) > threshold && ! boolstart
55
+ && !isAnyIndexDistributionZero (indexDistribution ,i +1 ,i +2 ,i +3 )){
58
56
boolstart = true ;
59
57
start = i ;
60
58
continue ;
61
59
}
62
60
}
63
- if (boolstart ) {
64
- if (indexDistribution .get (i ).intValue () == 0
65
- || indexDistribution .get (i +1 ).intValue () == 0 ) {
61
+ if (boolstart && isAnyIndexDistributionZero (indexDistribution ,i ,i +1 )) {
62
+
66
63
end = i ;
67
64
boolend = true ;
68
- }
65
+
69
66
}
67
+
68
+
70
69
StringBuilder tmp = new StringBuilder ();
71
70
if (boolend ) {
72
71
//System.out.println(start+1 + "\t\t" + end+1);
@@ -83,9 +82,27 @@ public String select(String html) {
83
82
}
84
83
return text .toString ();
85
84
}
86
-
85
+
86
+
87
87
@ Override
88
88
public List <String > selectList (String text ) {
89
89
throw new UnsupportedOperationException ();
90
90
}
91
+
92
+ private static boolean isAnyIndexDistributionZero ( ArrayList <Integer > indexDistribution , int index , int successorIndex , int afterSuccessorIndex = null ) {
93
+
94
+
95
+ if (afterSuccessorIndex != null ) {
96
+ return (indexDistribution .get (index ).intValue () == 0
97
+ && indexDistribution .get (indexSuccessor ).intValue () == 0
98
+ && indexDistribution .get (afterSuccessorIndex ).intValue () == 0 );
99
+ }else {
100
+ return (indexDistribution .get (index ).intValue () == 0
101
+ || indexDistribution .get (indexSuccessor ).intValue () == 0 );
102
+ }
103
+
104
+ }
105
+
106
+
107
+
91
108
}
0 commit comments