forked from zhuli8805/CBT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRun.py
96 lines (75 loc) · 3.97 KB
/
Run.py
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 28 16:22:50 2016
@author: ZHULI
"""
import _thread
from LanguageModel import answer_Trigramsimple
from TrigramModel import Run_BuildData
from TrigramModel_WP import Run_BuildData_WP
def BuildDataSingleThreads():
Run_BuildData(isStop = False, isStem = False, isReversed = False)
Run_BuildData(isStop = False, isStem = False, isReversed = True)
# Run_BuildData(isStop = True, isStem = True, isReversed = False)
# Run_BuildData(isStop = True, isStem = True, isReversed = True)
# Run_BuildData(isStop = True, isStem = False, isReversed = False)
# Run_BuildData(isStop = True, isStem = False, isReversed = True)
# Run_BuildData(isStop = False, isStem = True, isReversed = False)
# Run_BuildData(isStop = False, isStem = True, isReversed = True)
# Run_BuildData(isStop = True, isStem = True, isReversed = False)
# Run_BuildData(isStop = True, isStem = True, isReversed = True)
# Run_BuildData(isStop = True, isStem = False, isReversed = False)
# Run_BuildData(isStop = True, isStem = False, isReversed = True)
# Run_BuildData(isStop = False, isStem = True, isReversed = False)
# Run_BuildData(isStop = False, isStem = True, isReversed = True)
# Run_BuildData(isStop = False, isStem = False, isReversed = False)
# Run_BuildData(isStop = False, isStem = False, isReversed = True)
def BuildDataThread(isReversed, Nothing):
Run_BuildData(isStop = False, isStem = False, isReversed = isReversed)
Run_BuildData(isStop = False, isStem = True, isReversed = isReversed)
Run_BuildData(isStop = True, isStem = False, isReversed = isReversed)
Run_BuildData(isStop = True, isStem = True, isReversed = isReversed)
Run_BuildData(isStop = False, isStem = False, isReversed = isReversed)
Run_BuildData(isStop = True, isStem = True, isReversed = isReversed)
Run_BuildData(isStop = True, isStem = False, isReversed = isReversed)
Run_BuildData(isStop = False, isStem = True, isReversed = isReversed)
def BuildDataTwoThreads():
_thread.start_new_thread(BuildDataThread, (True, True))
_thread.start_new_thread(BuildDataThread, (False, False))
def BuildDataMultiThreads():
for isstop in [True, False]:
for isstem in [True, False]:
for isrev in [True, False]:
_thread.start_new_thread(Run_BuildData, (False, isstop, isstem, isrev))
testFiles = [
'..\..\..\..\CBTest Datasets\CBTest\data\cbtest_CN_test_2500ex.txt',
'..\..\..\..\CBTest Datasets\CBTest\data\cbtest_NE_test_2500ex.txt',
'..\..\..\..\CBTest Datasets\CBTest\data\cbtest_P_test_2500ex.txt',
'..\..\..\..\CBTest Datasets\CBTest\data\cbtest_V_test_2500ex.txt']
def RunTestSingleThread():
for filename in testFiles:
answer_Trigramsimple(True, True, filename)
answer_Trigramsimple(True, False, filename)
answer_Trigramsimple(False, True, filename)
answer_Trigramsimple(False, False, filename)
print('======================')
def RunTestMultiThreads():
def run4conditions(filename, nothing):
answer_Trigramsimple(True, True, filename)
answer_Trigramsimple(True, False, filename)
answer_Trigramsimple(False, True, filename)
answer_Trigramsimple(False, False, filename)
for filename in testFiles:
_thread.start_new_thread(run4conditions, (filename, 1))
def BuildData_WP():
for isPOS in [True, False]:
for isStop in [True, False]:
for isStem in [True, False]:
Run_BuildData_WP(isPOS = isPOS, isStop = isStop, isStem = isStem, isReversed = False)
Run_BuildData_WP(isPOS = isPOS, isStop = isStop, isStem = isStem, isReversed = True)
#BuildDataSingleThreads()
#BuildDataTwoThreads()
#BuildDataMultiThreads()
BuildData_WP()
#RunTestSingleThread()
#RunTestMultiThreads()