@@ -107,7 +107,7 @@ private void findByAuthorYear(String fullText, BibEntry citation, DocumentPositi
107107 }
108108 }
109109
110- refPattern = Pattern .compile ("([A-Z][^\\ s\\ .]+)\\ s+et\\ s+al\\ .\\ s+\\ ((\\ d\\ d \\ d \\ d )\\ )" );
110+ refPattern = Pattern .compile ("([A-Z][^\\ s\\ .]+)\\ s+et\\ s+al\\ .\\ s+\\ ((\\ d{4} )\\ )" );
111111 refMatcher = refPattern .matcher (fullText );
112112 while (refMatcher .find ()) {
113113 String year = refMatcher .group (2 );
@@ -119,7 +119,7 @@ private void findByAuthorYear(String fullText, BibEntry citation, DocumentPositi
119119 }
120120 }
121121
122- refPattern = Pattern .compile ("([A-Z][^\\ s\\ .]+)\\ s+(and|&)\\ s+[A-Z][^\\ s\\ .]+\\ s+\\ ((\\ d\\ d \\ d \\ d )\\ )" );
122+ refPattern = Pattern .compile ("([A-Z][^\\ s\\ .]+)\\ s+(and|&)\\ s+[A-Z][^\\ s\\ .]+\\ s+\\ ((\\ d{4} )\\ )" );
123123 refMatcher = refPattern .matcher (fullText );
124124 while (refMatcher .find ()) {
125125 String year = refMatcher .group (3 );
@@ -131,7 +131,7 @@ private void findByAuthorYear(String fullText, BibEntry citation, DocumentPositi
131131 }
132132 }
133133
134- refPattern = Pattern .compile ("([A-Z][^\\ s\\ .]+)\\ s+\\ ((\\ d\\ d \\ d \\ d )\\ )" );
134+ refPattern = Pattern .compile ("([A-Z][^\\ s\\ .]+)\\ s+\\ ((\\ d{4} )\\ )" );
135135 refMatcher = refPattern .matcher (fullText );
136136 while (refMatcher .find ()) {
137137 String year = refMatcher .group (2 );
@@ -164,7 +164,7 @@ private void findByAuthorYearFuzzy(String fullText, BibEntry citation, DocumentP
164164
165165 private void findByNumber (String fullText , BibEntry citation , String leftBracket , String rightBracket ,
166166 DocumentPositions positions ) {
167- Pattern numberPattern = Pattern .compile ("^[^\\ d]{0,10}(\\ d+ )" );
167+ Pattern numberPattern = Pattern .compile ("^[^\\ d]{0,10}(\\ d{1,5} )" );
168168 Matcher numberMatcher = numberPattern .matcher (citation .getText ());
169169 String number ;
170170 if (numberMatcher .find ()) {
@@ -181,14 +181,16 @@ private void findByNumber(String fullText, BibEntry citation, String leftBracket
181181 if (number .equals (match )) {
182182 positions .addPosition (citation , refMatcher .start (1 ), refMatcher .end (1 ));
183183 } else {
184- Pattern rangePattern = Pattern .compile ("^(\\ d+ )[" + String .valueOf (CharacterUtils .DASH_CHARS ) + "](\\ d+ )$" );
184+ Pattern rangePattern = Pattern .compile ("^(\\ d{1,5} )[" + String .valueOf (CharacterUtils .DASH_CHARS ) + "](\\ d{1,5} )$" );
185185 Matcher rangeMatcher = rangePattern .matcher (match );
186186 if (rangeMatcher .find ()) {
187- int lower = Integer .parseInt (rangeMatcher .group (1 ));
188- int upper = Integer .parseInt (rangeMatcher .group (2 ));
189- if (TextUtils .isNumberBetween (number , lower , upper +1 )) {
190- positions .addPosition (citation , refMatcher .start (1 ), refMatcher .end (1 ));
191- }
187+ try {
188+ int lower = Integer .parseInt (rangeMatcher .group (1 ));
189+ int upper = Integer .parseInt (rangeMatcher .group (2 ));
190+ if (TextUtils .isNumberBetween (number , lower , upper +1 )) {
191+ positions .addPosition (citation , refMatcher .start (1 ), refMatcher .end (1 ));
192+ }
193+ } catch (NumberFormatException e ) {}
192194 }
193195 }
194196 }
0 commit comments