-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLearningTest.swift
75 lines (49 loc) · 1.81 KB
/
LearningTest.swift
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// LearningTest.swift
// SwiftTests
//
// Created by Wayne Bishop on 10/22/18.
// Copyright © 2018 Arbutus Software Inc. All rights reserved.
//
import XCTest
@testable import SwiftStructures
class LearningTest: XCTestCase {
override func setUp() {
super.setUp()
}
//establish a positive test
func testAEClassifierAccurate() {
let statement = "The solar system has eight planets"
guard let result: AEClassifierResult = self.buildAELearningModel(with: statement) else {
print("test failed: no predicted value for AEClassifier..")
XCTFail()
return
}
if result != "accurate" {
print("accurate statement not identified by AEClassifier..")
XCTFail()
return
}
}
//establish a negative test
func testAEClassifierExaggeration() {
let statement = "It always rains in Seattle"
guard let result: AEClassifierResult = self.buildAELearningModel(with: statement) else {
print("test failed: no predicted value for AEClassifier..")
XCTFail()
return
}
if result != "exaggeration" {
print("exaggerated statement not identified by AEClassifier..")
XCTFail()
return
}
}
//helper function - build machine learning model
func buildAELearningModel(with prediction: String) -> AEClassifierResult? {
//create a new learning instance using AEClassifier
let learning = Learning()
let results = learning.AEPredict(using: prediction)
return results
}
}