Skip to content
This repository has been archived by the owner on Aug 15, 2020. It is now read-only.

Commit

Permalink
tweaked a few python 2/3 syntaxes
Browse files Browse the repository at this point in the history
  • Loading branch information
wboag committed Feb 23, 2018
1 parent 6e20c7d commit fe832e9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion code/feature_extraction/word_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def feature_length(word):
def feature_stem_porter(word):
try:
return {('stem_porter', porter_st.stem(word)): 1}
except Exception, e:
except Exception as e:
return {}

def feature_mitre(word):
Expand Down
12 changes: 1 addition & 11 deletions code/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,10 @@

from notes.documents import labels as tag2id, id2tag
from tools import flatten, save_list_structure, reconstruct_list
from tools import print_str, print_vec, print_files
from tools import print_str, print_vec, print_files, write



# python2 needs to convert to unicdode, but thats default for python3
if sys.version_info.major == 2:
tostr = unicode
else:
tostr = str

def write(f, s):
f.write(tostr(s))



class ClinerModel:

Expand Down
12 changes: 12 additions & 0 deletions code/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


import os
import sys
import errno
import string
import math
Expand Down Expand Up @@ -232,6 +233,17 @@ def print_files(f, file_names):



# python2 needs to convert to unicdode, but thats default for python3
if sys.version_info.major == 2:
tostr = unicode
else:
tostr = str

def write(f, s):
f.write(tostr(s))



def print_vec(f, label, vec):
'''
print_vec()
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ python-crfsuite
numpy
scipy
scikit-learn
marisa-trie
repoze.lru

0 comments on commit fe832e9

Please sign in to comment.