Skip to content

Commit

Permalink
add the fields section_number
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed May 8, 2024
1 parent 7ba9746 commit ac4447b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 4 additions & 5 deletions app/Helpers/TextChunker.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php
<?php

namespace App\Helpers;

class TextChunker {


class TextChunker
{
public static function handle(string $text, int $chunkSize = 600, int $overlapSize = 100): array
{
$chunks = [];
Expand All @@ -24,4 +23,4 @@ public static function handle(string $text, int $chunkSize = 600, int $overlapSi

return $chunks;
}
}
}
8 changes: 3 additions & 5 deletions tests/Feature/TextChunkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Tests\Feature;

use App\Helpers\TextChunker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

class TextChunkerTest extends TestCase
Expand All @@ -14,19 +12,19 @@ class TextChunkerTest extends TestCase
*/
public function test_chunking(): void
{
$text = get_fixture("chunkable_text.txt", false);
$text = get_fixture('chunkable_text.txt', false);

$results = TextChunker::handle($text);

$this->assertCount(4, $results);

$text = get_fixture("chunkable_text.txt", false);
$text = get_fixture('chunkable_text.txt', false);

$results = TextChunker::handle($text, 300, 100);

$this->assertCount(9, $results);

//put_fixture("chunkable_text_results.json", $results);
$this->assertEquals(get_fixture("chunkable_text_results.json"), $results);
$this->assertEquals(get_fixture('chunkable_text_results.json'), $results);
}
}

0 comments on commit ac4447b

Please sign in to comment.