-
Notifications
You must be signed in to change notification settings - Fork 0
/
matchNotesGraph.py
28 lines (22 loc) · 953 Bytes
/
matchNotesGraph.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
class SegmentationProblem(util.SearchProblem):
def __init__(self, query, unigramCost):
self.query = query
self.unigramCost = unigramCost
def startState(self):
return 0
def isEnd(self, state):
# BEGIN_YOUR_CODE (our solution is 2 lines of code, but don't worry if you deviate from this)
raise Exception("Not implemented yet")
# END_YOUR_CODE
def succAndCost(self, state):
# BEGIN_YOUR_CODE (our solution is 7 lines of code, but don't worry if you deviate from this)
raise Exception("Not implemented yet")
# END_YOUR_CODE
def segmentWords(query, unigramCost):
if len(query) == 0:
return ''
ucs = util.UniformCostSearch(verbose=0)
ucs.solve(SegmentationProblem(query, unigramCost))
# BEGIN_YOUR_CODE (our solution is 3 lines of code, but don't worry if you deviate from this)
raise Exception("Not implemented yet")
# END_YOUR_CODE