-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewritten highlighting algorithm. IrregularWordsStemmerInterface is r…
…emoved as it is not used anymore.
- Loading branch information
Showing
18 changed files
with
434 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* @copyright 2024 Roman Parpalak | ||
* @license https://opensource.org/license/mit MIT | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace S2\Rose\Entity; | ||
|
||
class HighlightIntervals | ||
{ | ||
protected array $highlightIntervals = []; | ||
protected bool $hasPreviousInterval = false; | ||
|
||
public function addInterval(int $start, int $end): void | ||
{ | ||
if (!$this->hasPreviousInterval) { | ||
$this->highlightIntervals[] = [$start, $end]; | ||
} else { | ||
$this->highlightIntervals[\count($this->highlightIntervals) - 1][1] = $end; | ||
} | ||
|
||
$this->hasPreviousInterval = true; | ||
} | ||
|
||
public function skipInterval(): void | ||
{ | ||
$this->hasPreviousInterval = false; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return $this->highlightIntervals; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.