emilmont / pyStatParser

Simple Python Statistical Parser
Apache License 2.0
109 stars 49 forks source link

temp file handling #9

Open brianray opened 8 years ago

brianray commented 8 years ago

Noticed when my installation tried to write to /usr/local/lib/python2.7/dist-packages/stat_parser/temp


Building the Grammar Model
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-2-29f6a952f468> in <module>()
      4 os.environ['DISPLAY'] = 'localhost:10.0'
      5 sent = "Each of us is full of shit in our own special way"
----> 6 parser = Parser()
      7 parser.parse(sent)
      8 tree = parser.parse(sent) # returns nltk Tree instance

/usr/local/lib/python2.7/dist-packages/stat_parser/parser.pyc in __init__(self, pcfg)
     78     def __init__(self, pcfg=None):
     79         if pcfg is None:
---> 80             pcfg = build_model()
     81 
     82         self.pcfg = pcfg

/usr/local/lib/python2.7/dist-packages/stat_parser/learn.pyc in build_model()
     26 
     27         if not exists(TEMP_DIR):
---> 28             makedirs(TEMP_DIR)
     29 
     30         # Normalise the treebanks

/usr/lib/python2.7/os.pyc in makedirs(name, mode)
    155         if tail == curdir:           # xxx/newdir/. exists if xxx/newdir exists
    156             return
--> 157     mkdir(name, mode)
    158 
    159 def removedirs(name):

OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/stat_parser/temp'

Wouldn't it be better to use a https://docs.python.org/2/library/tempfile.html or something else?

Fixed by manually creating that file and chmod'ing it as work around.