Skip to content

Commit

Permalink
encoding done
Browse files Browse the repository at this point in the history
  • Loading branch information
thedark10rd authored and thedark10rd committed Mar 7, 2017
1 parent 8e7e0f8 commit 64d20c8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pattern/vector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ def decode_string(v, encoding="utf-8"):
return unicode(v)


def encode_string(v, encoding="utf-8"):
encoding = ((encoding,),) + (("windows-1252",), ("utf-8", "ignore"),("utf-16",))
for e in encoding:
try:
return v.encode(*e)
except:
pass
return v
'''
def encode_string(v, encoding="utf-8"):
"""Returns the given value as a Python byte string (if possible)."""
if isinstance(encoding, basestring):
Expand All @@ -114,7 +124,7 @@ def encode_string(v, encoding="utf-8"):
pass
return v
return str(v)

'''
decode_utf8 = decode_string
encode_utf8 = encode_string

Expand Down

1 comment on commit 64d20c8

@shgaurav1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for test_vector.py the encoding error is gone. Regarding other 2 errors its because there are two classes missing from the file liblinearutil.py "parameter" and "problem".

Please sign in to comment.