Skip to content

Commit 6720631

Browse files
Merge branch 'fixDetection-873' into 'main'
Resolve problemas de detecção See merge request softwares-pkp/plugins_ojs/verificacao-metadados-documento!34
2 parents 44b8ba9 + d70539a commit 6720631

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

classes/ContentParser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ private function parseWordsFromString($string)
5151

5252
private function parseLine($line)
5353
{
54+
$line = preg_replace('/\x{200B}/u', '', $line);
5455
$lineWords = $this->parseWordsFromString($line);
5556

5657
if (!empty($lineWords) && is_numeric($lineWords[0])) {
@@ -63,7 +64,7 @@ private function parseLine($line)
6364
public function parseDocument($pathFile)
6465
{
6566
$pathTxt = substr($pathFile, 0, -3) . 'txt';
66-
shell_exec("pdftotext " . $pathFile . " " . $pathTxt . " -layout 2>/dev/null");
67+
shell_exec("pdftotext " . $pathFile . " " . $pathTxt . " -raw 2>/dev/null");
6768

6869
$docText = file_get_contents($pathTxt);
6970
$docLines = preg_split("/\r\n|\n|\r/", $docText);

classes/DocumentChecker.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,21 @@ private function checkForPattern($patterns, $limit, $limiarForWord, $limiarForPa
129129
{
130130
for ($i = 0; $i < count($this->words) - $limit; $i++) {
131131
for ($j = 0; $j < count($patterns); $j++) {
132-
$depth = 0;
132+
$depth = $similarWords = 0;
133133

134134
foreach ($patterns[$j] as $wordPattern) {
135135
$wordFromText = $this->words[$i + $depth];
136136
similar_text($wordFromText, $wordPattern, $similarity);
137-
if ($similarity < $limiarForWord) {
137+
$depth++;
138+
139+
if ($similarity < $limiarForWord && $similarWords == 0) {
138140
break;
139-
} else {
140-
$depth++;
141+
} else if ($similarity >= $limiarForWord) {
142+
$similarWords++;
141143
}
142144
}
143145

144-
if ($depth / count($patterns[$j]) >= $limiarForPattern) {
146+
if ($similarWords / count($patterns[$j]) >= $limiarForPattern) {
145147
return 'Success';
146148
}
147149
}

classes/DocumentChecklist.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,4 @@ private function getTitleInEnglishStatus($submission)
102102
'titleInEnglish' => $titleInEnglish
103103
];
104104
}
105-
106105
}

cypress/tests/Test3_nonArticleChecklist.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('Content Analysis Plugin - Non-article checklist execution', function()
7272
});
7373

7474
cy.get('#userDetailsForm .submitFormButton').click();
75-
cy.waitJQuery();
75+
cy.wait(2000);
7676
});
7777
it('Non-article checklist execution on PDF without any patterns', function() {
7878
cy.login('eostrom', null, 'publicknowledge');

tests/DetectionOnDocumentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function setUp(): void
1919

2020
protected function insertWordsIntoDocWordList($words, $docWordList)
2121
{
22-
$middlePosition = (int) count($docWordList) / 2;
22+
$middlePosition = (int) (count($docWordList) / 2);
2323

2424
return array_merge(
2525
array_slice($docWordList, 0, $middlePosition),

version.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<version>
1313
<application>contentAnalysis</application>
1414
<type>plugins.generic</type>
15-
<release>2.2.3.2</release>
16-
<date>2025-12-10</date>
15+
<release>2.2.4.0</release>
16+
<date>2026-01-06</date>
1717
<lazy-load>1</lazy-load>
1818
<class>ContentAnalysisPlugin</class>
1919
</version>

0 commit comments

Comments
 (0)