Skip to content
Snippets Groups Projects
Commit 0d01158b authored by Caroline de Pourtalès's avatar Caroline de Pourtalès :speech_balloon:
Browse files

predict links with drawing possible

parent 76abb835
No related branches found
No related tags found
1 merge request!3Prepare paper
......@@ -440,7 +440,7 @@ class Linker(Module):
with torch.no_grad():
self.cpu()
self.device = torch.device("cpu")
sentences_tokens, sentences_mask = self.Supertagger.sent_tokenizer.fit_transform_tensors([sentence])
sentences_tokens, sentences_mask = self.Supertagger.sent_tokenizer.fit_transform_tensors(sentence)
nb_sentence, len_sentence = sentences_tokens.shape
hidden_state, categories = self.Supertagger.predict(sentence)
......
......@@ -113,7 +113,8 @@ def draw_sentence_output(sentence, categories, links):
return dot.source
sentence = ["Le", "chat", "est", "noir", "bleu"]
categories = ["dr(0,s,n)", "dl(0,s,n)", "dr(0,dl(0,n,np),n)", "dl(0,np,n)", "n"]
links = np.array([[0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 2, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
draw_sentence_output(sentence, categories, links)
if __name__== '__main__':
sentence = ["Le", "chat", "est", "noir", "bleu"]
categories = ["dr(0,s,n)", "dl(0,s,n)", "dr(0,dl(0,n,np),n)", "dl(0,np,n)", "n"]
links = np.array([[0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 2, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
draw_sentence_output(sentence, categories, links)
from NeuralProofNet.NeuralProofNet import NeuralProofNet
from postprocessing import draw_sentence_output
# region data
a_s = "( 1 ) parmi les huit \" partants \" acquis ou potentiels , MM. Lacombe , Koehler et Laroze ne sont pas membres " \
"du PCF . "
a_s = ["( 1 ) parmi les huit \" partants \" acquis ou potentiels , MM. Lacombe , Koehler et Laroze ne sont pas membres du PCF ."]
tags_s = ['let', 'dr(0,s,s)', 'let', 'dr(0,dr(0,s,s),np)', 'dr(0,np,n)', 'dr(0,n,n)', 'let', 'n', 'let', 'dl(0,n,n)',
'dr(0,dl(0,dl(0,n,n),dl(0,n,n)),dl(0,n,n))', 'dl(0,n,n)', 'let', 'dr(0,np,np)', 'np', 'dr(0,dl(0,np,np),np)',
'np', 'dr(0,dl(0,np,np),np)', 'np', 'dr(0,dl(0,np,s),dl(0,np,s))', 'dr(0,dl(0,np,s),np)', 'dl(1,s,s)', 'np',
......@@ -20,7 +20,10 @@ neuralproofnet.linker.load_weights(model)
# region prediction
linker = neuralproofnet.linker
links = linker.predict_without_categories(a_s)
categories, links = linker.predict_without_categories(a_s)
#links = linker.predict_with_categories(a_s, tags_s)
print(links)
# endregion
\ No newline at end of file
# endregion
if __name__== '__main__':
idx=0
draw_sentence_output(a_s[idx].split(" "), categories[idx], links[:,idx,:].numpy())
\ No newline at end of file
......@@ -2,12 +2,8 @@ from SuperTagger.SuperTagger.SuperTagger import SuperTagger
from SuperTagger.SuperTagger.eval import categorical_accuracy
# region data
a_s = "( 1 ) parmi les huit \" partants \" acquis ou potentiels , MM. Lacombe , Koehler et Laroze ne sont pas membres " \
"du PCF . "
tags_s = [['let', 'dr(0,s,s)', 'let', 'dr(0,dr(0,s,s),np)', 'dr(0,np,n)', 'dr(0,n,n)', 'let', 'n', 'let', 'dl(0,n,n)',
'dr(0,dl(0,dl(0,n,n),dl(0,n,n)),dl(0,n,n))', 'dl(0,n,n)', 'let', 'dr(0,np,np)', 'np', 'dr(0,dl(0,np,np),np)',
'np', 'dr(0,dl(0,np,np),np)', 'np', 'dr(0,dl(0,np,s),dl(0,np,s))', 'dr(0,dl(0,np,s),np)', 'dl(1,s,s)', 'np',
'dr(0,dl(0,np,np),n)', 'n', 'dl(0,s,txt)']]
a_s = "85,6 % de membres du PCF ."
tags_s = [['dr(0,np,n)', 'n', 'dr(0,dl(0,np,np),n)', 'n', 'dr(0,dl(0,n,n),n)', 'n', 'dl(0,np,txt)']]
# endregion
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment