3
3
import ai .elimu .model .v2 .enums .ReadingLevel ;
4
4
import org .junit .jupiter .api .Test ;
5
5
6
- import java .io .IOException ;
7
-
8
6
import static org .junit .jupiter .api .Assertions .assertEquals ;
9
- import static org .junit .jupiter .api .Assertions .assertThrows ;
10
7
11
8
public class ReadingLevelUtilTest {
12
9
13
10
@ Test
14
11
public void testPredictReadingLevel_Level1 () {
15
12
16
- String modelFilePath = "src/test/resources/ai/elimu/util/reading_level/model1.pmml" ;
17
- int chapterCount = 5 ;
18
- int paragraphCount = 20 ;
19
- int wordCount = 100 ;
13
+ int chapterCount = 12 ;
14
+ int paragraphCount = 18 ;
15
+ int wordCount = 150 ;
20
16
21
- ReadingLevel result = ReadingLevelUtil .predictReadingLevel (chapterCount , paragraphCount , wordCount , modelFilePath );
17
+ ReadingLevel result = ReadingLevelUtil .predictReadingLevel (chapterCount , paragraphCount , wordCount );
22
18
assertEquals (ReadingLevel .LEVEL1 , result , "Expected ReadingLevel to be LEVEL1, but got: " + result );
23
19
24
20
}
25
21
26
22
@ Test
27
23
public void testPredictReadingLevel_Level2 () {
28
24
29
- String modelFilePath = "src/test/resources/ai/elimu/util/reading_level/model1.pmml" ;
30
- int chapterCount = 12 ;
31
- int paragraphCount = 22 ;
32
- int wordCount = 250 ;
25
+ int chapterCount = 20 ;
26
+ int paragraphCount = 30 ;
27
+ int wordCount = 300 ;
33
28
34
- ReadingLevel result = ReadingLevelUtil .predictReadingLevel (chapterCount , paragraphCount , wordCount , modelFilePath );
29
+ ReadingLevel result = ReadingLevelUtil .predictReadingLevel (chapterCount , paragraphCount , wordCount );
35
30
assertEquals (ReadingLevel .LEVEL2 , result , "Expected ReadingLevel to be LEVEL2, but got: " + result );
36
31
37
32
}
38
33
39
34
@ Test
40
35
public void testPredictReadingLevel_Level3 () {
41
36
42
- String modelFilePath = "src/test/resources/ai/elimu/util/reading_level/model1.pmml" ;
43
- int chapterCount = 12 ;
44
- int paragraphCount = 25 ;
37
+ int chapterCount = 25 ;
38
+ int paragraphCount = 40 ;
45
39
int wordCount = 350 ;
46
40
47
- ReadingLevel result = ReadingLevelUtil .predictReadingLevel (chapterCount , paragraphCount , wordCount , modelFilePath );
41
+ ReadingLevel result = ReadingLevelUtil .predictReadingLevel (chapterCount , paragraphCount , wordCount );
48
42
assertEquals (ReadingLevel .LEVEL3 , result , "Expected ReadingLevel to be LEVEL3, but got: " + result );
49
43
50
44
}
51
45
52
46
@ Test
53
- public void testPredictReadingLevel_InvalidModelFile () {
47
+ public void testPredictReadingLevel_Level4 () {
48
+
49
+ int chapterCount = 15 ;
50
+ int paragraphCount = 45 ;
51
+ int wordCount = 559 ;
52
+
53
+ ReadingLevel result = ReadingLevelUtil .predictReadingLevel (chapterCount , paragraphCount , wordCount );
54
+ assertEquals (ReadingLevel .LEVEL4 , result , "Expected ReadingLevel to be LEVEL4, but got: " + result );
54
55
55
- assertThrows (IOException .class , () -> {
56
- ReadingLevelUtil .predictReadingLevel (1 , 1 , 1 , "invalidPath" );
57
- }, "Expected IOException when loading an invalid model file path" );
58
56
}
59
57
}
0 commit comments