Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 3 update with contrib error corrected #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
2 changes: 1 addition & 1 deletion NSpM-project/ask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

cd nmt
echo "$2" > to_ask.txt
python -m nmt.nmt --vocab_prefix=../$1/vocab --model_dir=../$1_model --inference_input_file=./to_ask.txt --inference_output_file=./output.txt --out_dir=../$1_model --src=en --tgt=sparql | tail -n4
python -m nmt.nmt --vocab_prefix=../$1_model/vocab --model_dir=../$1_model --inference_input_file=./to_ask.txt --inference_output_file=./output.txt --out_dir=../$1_model --src=en --tgt=sparql | tail -n4

if [ $? -eq 0 ]
then
Expand Down
8 changes: 4 additions & 4 deletions NSpM-project/generator_utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import collections
import httplib
import http.client
import json
import logging
import re
import sys
import urllib
import urllib2
from urllib.request import urlopen

ENDPOINT = "http://dbpedia.org/sparql"
GRAPH = "http://dbpedia.org"
Expand Down Expand Up @@ -44,10 +44,10 @@ def query_dbpedia( query ):
param["timeout"] = "600" # ten minutes - works with Virtuoso endpoints
param["debug"] = "on"
try:
resp = urllib2.urlopen(ENDPOINT + "?" + urllib.urlencode(param))
resp = urllib.request.urlopen(ENDPOINT + "?" + urllib.parse.urlencode(param))
j = resp.read()
resp.close()
except (urllib2.HTTPError, httplib.BadStatusLine):
except (urllib.error.HTTPError, http.client.BadStatusLine):
logging.debug("*** Query error. Empty result set. ***")
j = '{ "results": { "bindings": [] } }'
sys.stdout.flush()
Expand Down
6 changes: 3 additions & 3 deletions NSpM-project/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

"""
import sys

from importlib import reload
from generator_utils import decode

if __name__ == '__main__':
reload(sys)
sys.setdefaultencoding("utf-8")
#sys.setdefaultencoding("utf-8")

encoded_sparql = sys.argv[1]
decoded_sparql = decode(encoded_sparql)
print decoded_sparql
print(decoded_sparql)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion NSpM-project/nmt/nmt/model_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def create_infer_model(model_creator, hparams, scope=None, single_cell_fn=None):
src_placeholder = tf.placeholder(shape=[None], dtype=tf.string)
batch_size_placeholder = tf.placeholder(shape=[], dtype=tf.int64)

src_dataset = tf.contrib.data.Dataset.from_tensor_slices(
src_dataset = tf.data.Dataset.from_tensor_slices(
src_placeholder)
iterator = iterator_utils.get_infer_iterator(
src_dataset,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions NSpM-project/nmt/nmt/utils/misc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@


def check_tensorflow_version():
if tf.__version__ < "1.2.1":
raise EnvironmentError("Tensorflow version must >= 1.2.1")
if tf.__version__ < "1.15.0":
raise EnvironmentError("Tensorflow version must >= 1.15.0")


def safe_exp(value):
Expand Down
2 changes: 1 addition & 1 deletion NSpM-project/nmt/output.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
select var_a where brack_open <unk> dbo_abstract var_a brack_close
select var_a where brack_open dbr_Edward_VII_Monument_ par_open Montreal par_close dbo_location var_a brack_close
2 changes: 1 addition & 1 deletion NSpM-project/nmt/to_ask.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
what about the louvre
where is edward vii monument located in?