Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Sep 13, 2014
1 parent 6e4e487 commit bde4bbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frog_classes.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ cdef extern from "frog/FrogAPI.h":

FrogAPI(FrogOptions options, Configuration configuration, LogStream * logstream)

string Test( Document * doc, bool hidetimers = True) #returns results as string
string Testtostring( Document * doc) #returns results as string

#void Test( Document doc, ostream outStream, bool hidetimers = False, string xmlOutFile = "") nogil
#void Test( string infilename, ostream os, string xmlOutFile) nogil
Expand Down
9 changes: 6 additions & 3 deletions frog_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,17 @@ cdef class Frog:
def process_raw(self, str text):
"""Invokes Frog on the specified text, the text is considered one document. The raw results from Frog are return as a string"""
cdef libfolia_classes.Document * doc = self.capi.tokenizer.tokenizehelper( text.encode('utf-8') )
cdef string result = self.capi.Test(doc)
return result.decode('utf-8')
cdef string result = self.capi.Testtostring(doc)
r = result.decode('utf-8')
del doc
return r

def parsecolumns(self, str response):
"""Parse the raw Frog response"""
columns = ('index','text','lemma','morph','pos','posprob','ner','chunker','depindex','dep')
data = []
for line in response.split('\n'):
if line.strip():
if not line.strip():
if data:
data[-1]['eos'] = True
else:
Expand All @@ -155,6 +157,7 @@ cdef class Frog:
item[columns[i]] = float(field)
else:
item[columns[i]] = field
data.append(item)
return data


Expand Down

0 comments on commit bde4bbb

Please sign in to comment.