Port connection issue/How to load a local simplenlg.jar
tomdakin opened this issue · 2 comments
Hello Roman,
Thanks for taking the time to build this wrapper for simpleNLG. It is truly necessary!
I am trying to get it up and running but getting an error from the connection to 'nlg.kutlak.info', port 40000. Running your code from the front-page of your git:
`from nlglib.realisation.simplenlg.realisation import Realiser
from nlglib.microplanning import *
realise_en = Realiser(host='nlg.kutlak.info', port=40000)
realise_es = Realiser(host='nlg.kutlak.info', port=40001)
def main():
p = Clause("María", "perseguir", "un mono")
p['TENSE'] = 'PAST'
# expected = 'María persigue un mono.'
print(realise_es(p))
p = Clause(NP("la", "rápida", "corredora"), VP("perseguir"), NP("un", "mono"))
subject = NP("la", "corredora")
objekt = NP("un", "mono")
verb = VP("perseguir")
subject.premodifiers.append("rápida")
p.subject = subject
p.predicate = verb
p.object = objekt
# expected = 'La rápida corredora persigue un mono.'
print(realise_es(p))
p = Clause(NP('this', 'example'), VP('show', 'how cool simplenlg is'))
# expected = This example shows how cool simplenlg is.
print(realise_en(p))
if name == 'main':
main()`
I get the following output & error:
`María persiguió un mono.
La rápida corredora persigue un mono.
ConnectionRefusedError Traceback (most recent call last)
in ()
27
28 if name == 'main':
---> 29 main()
in main()
23 p = Clause(NP('this', 'example'), VP('show', 'how cool simplenlg is'))
24 # expected = This example shows how cool simplenlg is.
---> 25 print(realise_en(p))
26
27
/anaconda3/lib/python3.6/site-packages/nlglib-0.1.0-py3.6.egg/nlglib/realisation/simplenlg/realisation.py in call(self, msg, **kwargs)
25
26 def call(self, msg, **kwargs):
---> 27 return self.realise(msg, **kwargs)
28
29 def realise(self, msg, **kwargs):
/anaconda3/lib/python3.6/site-packages/nlglib-0.1.0-py3.6.egg/nlglib/realisation/simplenlg/realisation.py in realise(self, msg, **kwargs)
31 return ''
32 elif msg.category in category.element_category:
---> 33 return self.element(msg, **kwargs)
34 elif isinstance(msg, (list, set, tuple)) or msg.category == category.ELEMENT_LIST:
35 return self.element_list(msg, **kwargs)
/anaconda3/lib/python3.6/site-packages/nlglib-0.1.0-py3.6.egg/nlglib/realisation/simplenlg/realisation.py in element(self, elt, **kwargs)
53 elt.accept(v)
54 self.logger.debug('XML for realisation:\n{0}'.format(v.to_xml()))
---> 55 result = self.client.xml_request(v.to_xml())
56 return result.replace(' ,', ',')
/anaconda3/lib/python3.6/site-packages/nlglib-0.1.0-py3.6.egg/nlglib/realisation/simplenlg/client.py in xml_request(self, data)
121
122 def xml_request(self, data):
--> 123 with self.socket as sock:
124 sock.send_string(data)
125 result = sock.recv_string()
/anaconda3/lib/python3.6/site-packages/nlglib-0.1.0-py3.6.egg/nlglib/realisation/simplenlg/client.py in enter(self)
101 # allow the use in 'with' statement
102 def enter(self):
--> 103 self.connect()
104 return self
105
/anaconda3/lib/python3.6/site-packages/nlglib-0.1.0-py3.6.egg/nlglib/realisation/simplenlg/client.py in connect(self)
40 self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
41 try:
---> 42 self.socket.connect((self.host, self.port))
43 except OSError as msg:
44 self.socket.close()
ConnectionRefusedError: [Errno 61] Connection refused`
I notice you say in your tutorial that it is possible to connect to a simpleNLG server locally using the .jar file. I have been trying to do this in light of the above issue, but am having no luck. Could you advise how to do this please?
Many thanks,
Tom Dakin
Hi Tom!
I am hosting both the Spanish and the English SimpleNLG server on a single AWS micro instance and it occasionally runs out of memory (java...always memory hungry). Anyway, I have restarted the server so it should be working for a bit.
Regarding the local installation of SimpleNLG, I run it on the server with this command:
ava -Xmx750m -cp build/classes/:lib/lexAccess2011dist.jar simplenlg.server.SimpleServer 40000 ./src/main/resources/default-lexicon.xml
I am not sure whether the lexicon path is in the original SimpleNLG distribution. You might have to download my fork to get it working.
Best or luck :-)
PS: I have started a room/channel in gitter: https://gitter.im/nlglib/Lobby I haven't used it before but if you see me there I am happy to chat.
Hi Roman,
Many thanks for this! The SimpleNLG server is working a treat now.
Appreciate your help.
Tom