Skip to content

Commit

Permalink
Check for error opening flexrule file. Cleaned example.
Browse files Browse the repository at this point in the history
  • Loading branch information
BartJongejan committed Oct 11, 2021
1 parent bff2860 commit b1b4562
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions cstlempy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cdef extern from "tinylemmatizer.h":
def init(Str):
cdef int Err
startProc(bytes(Str,'iso8859-1'),&Err)
return Err

# Function to lemmatize a full form
def lemmatize(Str):
Expand Down
23 changes: 16 additions & 7 deletions launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@
import cstlempy

filename = "flexrules"
print("Initialise cstlempy with the call 'cstlempy.init("+filename+")'.\n")
cstlempy.init(filename)
print("Initialise cstlempy with the call 'cstlempy.init(\""+filename+"\")'.\n")
Err = cstlempy.init(filename)

if(Err == 0):
print("Initialization succeeded.\n")
cstlempyFullForm = "went"
print("Going to call lemmatize(<full form>).\n\nThe full form is this one: "+cstlempyFullForm)
answer = cstlempy.lemmatize(cstlempyFullForm)
print('Answer from cstlempy: '+answer+'\n')
elif(Err == 1):
print("Cannot open '" + filename + "'.\n")
elif(Err ==2):
print("Something went wrong while reading '" + filename + "'.\n")
else:
print("An unknown error occurred.\n")

cstlempyFullForm = "went"
print("Going to call lemmatize(<full form>).\n\nThe full form is this one: "+cstlempyFullForm)
answer = cstlempy.lemmatize(cstlempyFullForm)
print('Answer from cstlempy: '+answer+'\n')
cstlempy.final()
print("We have called cstlempy.final(), so now cstlempy is not available until we call\n'cstlempy.init()' again.")
print("We have called 'cstlempy.final()', so now cstlempy is not available until we call 'cstlempy.init()' again.")

0 comments on commit b1b4562

Please sign in to comment.