@@ -17,12 +17,14 @@ class DocumentChecker
1717{
1818 private $ pathFile ;
1919 public $ words ;
20+ public $ secondaryWords ;
2021
2122 public function __construct ($ path )
2223 {
2324 $ this ->pathFile = $ path ;
2425 $ parser = new ContentParser ();
2526 $ this ->words = $ parser ->parseDocument ($ path );
27+ $ this ->secondaryWords = $ parser ->parseDocument ($ path , false );
2628 }
2729
2830 private $ patternsContribution = [
@@ -125,14 +127,14 @@ private function checkOrcid($text)
125127 ["dados " , "da " , "pesquisa " ]
126128 ];
127129
128- private function checkForPattern ( $ patterns , $ limit , $ limiarForWord , $ limiarForPattern )
130+ private function checkForPatternsInWordList ( $ wordList , $ patterns , $ limit , $ limiarForWord , $ limiarForPattern )
129131 {
130- for ($ i = 0 ; $ i < count ($ this -> words ) - $ limit ; $ i ++) {
132+ for ($ i = 0 ; $ i < count ($ wordList ) - $ limit ; $ i ++) {
131133 for ($ j = 0 ; $ j < count ($ patterns ); $ j ++) {
132134 $ depth = $ similarWords = 0 ;
133135
134136 foreach ($ patterns [$ j ] as $ wordPattern ) {
135- $ wordFromText = $ this -> words [$ i + $ depth ];
137+ $ wordFromText = $ wordList [$ i + $ depth ];
136138 similar_text ($ wordFromText , $ wordPattern , $ similarity );
137139 $ depth ++;
138140
@@ -152,9 +154,20 @@ private function checkForPattern($patterns, $limit, $limiarForWord, $limiarForPa
152154 return 'Error ' ;
153155 }
154156
157+ public function checkForPatterns ($ patterns , $ limit , $ limiarForWord , $ limiarForPattern )
158+ {
159+ $ result = $ this ->checkForPatternsInWordList ($ this ->words , $ patterns , $ limit , $ limiarForWord , $ limiarForPattern );
160+
161+ if ($ result == 'Error ' ) {
162+ $ result = $ this ->checkForPatternsInWordList ($ this ->secondaryWords , $ patterns , $ limit , $ limiarForWord , $ limiarForPattern );
163+ }
164+
165+ return $ result ;
166+ }
167+
155168 public function checkAuthorsContribution ()
156169 {
157- return $ this ->checkForPattern ($ this ->patternsContribution , 3 , 75 , 1 );
170+ return $ this ->checkForPatterns ($ this ->patternsContribution , 3 , 75 , 1 );
158171 }
159172
160173 public function checkTextOrcidsNumber ()
@@ -176,17 +189,17 @@ public function checkTextOrcidsNumber()
176189
177190 public function checkConflictInterest ()
178191 {
179- return $ this ->checkForPattern ($ this ->patternsConflictInterest , 3 , 75 , 1 );
192+ return $ this ->checkForPatterns ($ this ->patternsConflictInterest , 3 , 75 , 1 );
180193 }
181194
182195 public function checkKeywordsInEnglish ()
183196 {
184- return $ this ->checkForPattern ($ this ->patternsKeywordsEnglish , 2 , 92 , 1 );
197+ return $ this ->checkForPatterns ($ this ->patternsKeywordsEnglish , 2 , 92 , 1 );
185198 }
186199
187200 public function checkAbstractInEnglish ()
188201 {
189- return $ this ->checkForPattern ($ this ->patternsAbstractEnglish , 2 , 92 , 1 );
202+ return $ this ->checkForPatterns ($ this ->patternsAbstractEnglish , 2 , 92 , 1 );
190203 }
191204
192205 public function checkTitleInEnglish ($ title )
@@ -199,16 +212,16 @@ public function checkTitleInEnglish($title)
199212 $ cleanedTitle = $ parser ->cleanStyledText ($ title );
200213 $ patternTitle = $ parser ->createPatternFromString ($ cleanedTitle );
201214
202- return $ this ->checkForPattern (array ($ patternTitle ), count ($ patternTitle ), 75 , 0.75 );
215+ return $ this ->checkForPatterns (array ($ patternTitle ), count ($ patternTitle ), 75 , 0.75 );
203216 }
204217
205218 public function checkEthicsCommittee ()
206219 {
207- return $ this ->checkForPattern ($ this ->patternsEthicsCommittee , 2 , 75 , 1 );
220+ return $ this ->checkForPatterns ($ this ->patternsEthicsCommittee , 2 , 75 , 1 );
208221 }
209222
210223 public function checkDataStatement ()
211224 {
212- return $ this ->checkForPattern ($ this ->patternsDataStatement , 3 , 90 , 1 );
225+ return $ this ->checkForPatterns ($ this ->patternsDataStatement , 3 , 90 , 1 );
213226 }
214227}
0 commit comments