xinyadu / nqg

neural question generation for reading comprehension

Home Page:https://arxiv.org/abs/1705.00106

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to run the code in colab

Binathi opened this issue · comments

I am trying to run this code from github on google colab.
To execute the code, i have to run the command "th preprocess.lua -config config-preprocess". Whenever I use this command on colab it says,

File "", line 1
th preprocess.lua -config config-preprocess
^
SyntaxError: invalid syntax

I tried installing Lua 5.2 on colab using the instructions in the link http://torch.ch/docs/getting-started.html .I ran the following commands
!git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch
!./clean.sh
!TORCH_LUA_VERSION=LUA52 ./install.sh
!luarocks install image
When I run the command !luarocks install image. It gives the error
/bin/bash: luarocks: command not found

Resolved it by running the following

#for Torch with Lua 5.3:
import os
os.environ['LUA_PATH'] = '/root/.luarocks/share/lua/5.3/?.lua;/root/.luarocks/share/lua/5.3/?/init.lua;/root/torch/install/share/lua/5.3/?.lua;/root/torch/install/share/lua/5.3/?/init.lua;/root/torch/install/lib/lua/5.3/?.lua;/root/torch/install/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua'
os.environ['LUA_CPATH'] ='/root/.luarocks/lib/lua/5.3/?.so;/root/torch/install/lib/lua/5.3/?.so;/root/torch/install/lib/lua/5.3/loadall.so;./?.so'
os.environ['PATH'] += ':/root/torch/install/bin'

if 'LD_LIBRARY_PATH' not in os.environ.keys():
os.environ['LD_LIBRARY_PATH'] = ''
else:
os.environ['LD_LIBRARY_PATH'] += ':'
os.environ['LD_LIBRARY_PATH'] +='/root/torch/install/lib'

if 'DYLD_LIBRARY_PATH' not in os.environ.keys():
os.environ['DYLD_LIBRARY_PATH'] = ''
else:
os.environ['DYLD_LIBRARY_PATH'] += ':'
os.environ['DYLD_LIBRARY_PATH'] +='/root/torch/install/lib'

if 'LUA_CPATH' not in os.environ.keys():
os.environ['LUA_CPATH'] = ''
else:
os.environ['LUA_CPATH'] += ';'
os.environ['LUA_CPATH'] += '/root/torch/install/lib/?.so'

!luarocks install tds