-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-chunking.php
More file actions
32 lines (24 loc) · 832 Bytes
/
test-chunking.php
File metadata and controls
32 lines (24 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Knowledge\Service\AI\ChunkingService;
$service = new ChunkingService();
$html = "
<h1>Title</h1>
<p>This is paragraph one. It has some text.</p>
<p>This is paragraph two. It is also short.</p>
<div class='content'>
<p>This is paragraph three. It is a bit longer to test the chunking logic and ensure that we are capturing enough context for the embedding model to work with.</p>
</div>
";
echo "Testing ChunkingService...\n";
$chunks = $service->chunk( $html, 50, 10 ); // Small chunk size to force splits
foreach ( $chunks as $i => $chunk ) {
echo "--- Chunk $i ---\n";
echo $chunk . "\n";
echo "Length: " . strlen($chunk) . "\n";
}
if ( count($chunks) > 0 ) {
echo "✅ Chunking Test Passed\n";
} else {
echo "❌ Chunking Test Failed\n";
}