File size: 1,479 Bytes
0f6a233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
import sail_kernel
print("sail_kernel version:", sail_kernel.__version__)

# Test 1: text cleaning
result = sail_kernel.clean_text("<b>Hello   World</b>\n\n\n\nFoo")
print("clean_text:", repr(result))

# Test 2: batch cleaning
batch = sail_kernel.clean_batch(["<p>First</p>", "<b>Second  text</b>", "Normal text"])
print("clean_batch:", batch)

# Test 3: dynamic token budget
budget = sail_kernel.compute_budget("Define photosynthesis. [2 marks]")
print("budget (2 marks):", budget)
budget8 = sail_kernel.compute_budget("Explain with examples how TCP/IP works. (8 marks)")
print("budget (8 marks):", budget8)
budget_deep = sail_kernel.compute_budget("Analyze and compare the causes of WW1 and WW2 in detail step-by-step")
print("budget (deep Q):", budget_deep)

# Test 4: reward scorer
score = sail_kernel.score_output("## Answer\n\n**Key point**: Use `cargo build`.\n\n- Item 1\n- Item 2", 500)
print("format-rich score:", score.format_score, "total:", score.total_score)

score_plain = sail_kernel.score_output("just plain text with no formatting at all", 100)
print("plain text score:", score_plain.format_score, "total:", score_plain.total_score)

# Test 5: batch reward scoring
scores = sail_kernel.score_batch([
    "## Section\n\n**Bold**: some content\n\n- list item",
    "plain text answer",
    "## Deep Answer\n\n**Critical**: step by step analysis\n\n```python\ncode```"
], target_tokens=300)
print("batch scores:", scores)

print("\nAll SAIL kernel tests PASSED!")