Commits

Anonymous committed 4790d45

removed gap

Comments (0)

Files changed (2)

         - improve this (e.g. make sure that connections are closed, socket-files are deleted etc.)
         - exception-handling? (socket.error)
     """
-    def __init__( self, addr, limit=4096, sock_type=socket.AF_INET, sock_prot=socket.SOCK_STREAM, timeout=1.0, logfunc=log_dummy ):
+    def __init__( self, addr, limit=4096, sock_type=socket.AF_INET, sock_prot=socket.SOCK_STREAM, timeout=5.0, logfunc=log_dummy ):
         """
         :Parameters:
             - addr: socket-address
     class TransportUnixSocket(TransportSocket):
         """Transport via Unix Domain Socket.
         """
-        def __init__(self, addr=None, limit=4096, timeout=1.0, logfunc=log_dummy):
+        def __init__(self, addr=None, limit=4096, timeout=5.0, logfunc=log_dummy):
             """
             :Parameters:
                 - addr: "socket_file"
 class TransportTcpIp(TransportSocket):
     """Transport via TCP/IP.
     """
-    def __init__(self, addr=None, limit=4096, timeout=1.0, logfunc=log_dummy):
+    def __init__(self, addr=None, limit=4096, timeout=5.0, logfunc=log_dummy):
         """
         :Parameters:
             - addr: ("host",port)
     state = 0
     tmp = {}
     results = []
-    for line in text.split("\n    "):
+    for line in text.split("\n"):
         if line.startswith("Sentence #"):
             state = 1
             if len(tmp.keys()) != 0:
                 results.append(tmp)
                 tmp = {}
         elif state == 1:
-            tmp['text'] = line
+            tmp['text'] = line.strip()
             state = 2
         elif state == 2:
             if not line.startswith("[Text="):
         
         # spawn the server
         self._server = pexpect.spawn("%s -Xmx3g -cp %s %s" % (javapath, ':'.join(jars), classname))
-
+        
+        print "Starting the Stanford Core NLP parser."
         # show progress bar while loading the models
-        widgets = ['Starting Server: ', Fraction(), ' ', Bar(marker=RotatingMarker()), ' ', ETA()]
+        widgets = ['Loading Models: ', Fraction(), ' ', Bar(marker=RotatingMarker()), ' ', ETA()]
         pbar = ProgressBar(widgets=widgets, maxval=5, force_update=True).start()
         self._server.expect("done.", timeout=20) # Load pos tagger model (~5sec)
         pbar.update(1)
             freshlen = len(ch)
             time.sleep (0.0001)
             incoming = incoming + ch
-            if end_time - time.time() < 0:
+            if "\nNLP>" in incoming or end_time - time.time() < 0:
                 break
-        return dumps(parse_parser_results(incoming))
+        results = parse_parser_results(incoming)
+        print "Results", results
+        # convert to JSON and return
+        return dumps(results)
 
 
 if __name__ == '__main__':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.