Skip to content

Commit

Permalink
Travis build fix, attempt 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jerinphilip committed May 28, 2016
1 parent 0e0233f commit 20f959c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
1 change: 0 additions & 1 deletion sandhisplitter/tests/test_trie.py
Expand Up @@ -29,7 +29,6 @@ def debug(self):
def contains_substr(self, node, word):
if not word:
return '$' in node.next.keys()
#head, *tail = word
head, tail = head_tail(word)
if head not in node.next.keys():
return False
Expand Down
3 changes: 0 additions & 3 deletions sandhisplitter/train.py
Expand Up @@ -2,10 +2,7 @@
Code to train the model using dataset
"""

from sandhisplitter.trie import Trie
import sys
import json


def usage():
string = "%s <datafile>" % (sys.argv[0])
Expand Down
9 changes: 4 additions & 5 deletions sandhisplitter/trie.py
@@ -1,5 +1,6 @@
from sandhisplitter.util import head_tail


class TrieNode:
def __init__(self, character):
self.character = character
Expand All @@ -18,7 +19,6 @@ def update_node(self, node, word):
node.next['$'] = self.end
node.c_sp += 1
else:
#head, *tail = word
head, tail = head_tail(word)
if head not in node.next.keys():
node.next[head] = TrieNode(head)
Expand All @@ -27,22 +27,21 @@ def update_node(self, node, word):

def add_word(self, word):
wordList = list(word)
self.update_node(self.root, word)
self.update_node(self.root, wordList)

def P_sp(self, word):
"""Returns probability of word being prefix to split point"""
wordList = list(word)
node = self.root
while(wordList):
#head, *tail = wordList
head, tail = head_tail(wordList)
head, tail = head_tail(wordList)
wordList = tail
if head not in node.next.keys():
return 0
node = node.next[head]
return (node.c_sp/(node.c_sp + node.c_nsp))

def P_nsp(word):
def P_nsp(self, word):
return 1 - self.P_sp(word)

def serialize_node(self, node):
Expand Down

0 comments on commit 20f959c

Please sign in to comment.