Skip to content

Commit

Permalink
change tag word order
Browse files Browse the repository at this point in the history
  • Loading branch information
isnowfy committed May 11, 2013
1 parent 303e878 commit 1fb5fea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions test_tnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def main():
if not line.strip():
continue
words = map(lambda x: x.split('/'), line.split(' '))
words = map(lambda x: (x[1], x[0]), words)
data.append(words)
model = tnt.TnT()
model.train(data)
Expand All @@ -21,7 +20,7 @@ def main():
for c1, sent in enumerate(data):
for c2, wd in enumerate(sent):
total += 1
if wd[0] != ret[c1][c2][0]:
if wd[1] != ret[c1][c2][1]:
error += 1
print 'total: %d, error: %d, precision: %f' % (total, error, float(error).total)

Expand Down
5 changes: 3 additions & 2 deletions tnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class TnT(object):

def __init__(self, N=1000):
self.N = 1000
self.N = N
self.l1 = 0.0
self.l2 = 0.0
self.l3 = 0.0
Expand Down Expand Up @@ -70,6 +70,7 @@ def train(self, data):

def tag(self, data):
now = [(('BOS', 'BOS'), 0.0, [])]
print self.status
for w in data:
stage = {}
for pre in now:
Expand All @@ -85,4 +86,4 @@ def tag(self, data):
stage = map(lambda x: (x[0], x[1][0], x[1][1]), stage.items())
now = sorted(stage, key=lambda x:-x[1])[:self.N]
print len(now)
return zip(now[2], data)
return zip(data, now[0][2])

0 comments on commit 1fb5fea

Please sign in to comment.