зеркало из https://github.com/microsoft/inmt.git
Added parameters for partial and full sentences suggestions (#25)
* API parameter for number of suggestions * Set n_best_partial in js Co-authored-by: Sebastin Santy <sebastinssanty@gmail.com>
This commit is contained in:
Родитель
3a5ac491c1
Коммит
af39c7dd08
|
@ -94,16 +94,11 @@ def translate_new(request):
|
|||
langspec = request.GET.get('langspec')
|
||||
sentence = request.GET.get('sentence')
|
||||
partial_trans = request.GET.get('partial_trans', '')
|
||||
n_words = request.GET.get('n_words', '')
|
||||
n_words = int(request.GET.get('n_words', '2'))
|
||||
n_best_partial = int(request.GET.get('n_best_partial', '5'))
|
||||
translatorbest = engines[langspec]["translatorbest"]
|
||||
translatorbigram = engines[langspec]["translatorbigram"]
|
||||
|
||||
#set the default value for number of words in the suggestions as 2
|
||||
n_suggestions = 2
|
||||
|
||||
if n_words != '':
|
||||
n_suggestions = int(n_words)
|
||||
|
||||
src_segmenter = engines[langspec]["src_segmenter"]
|
||||
|
||||
L1 = preprocess_src(sentence.strip(), [src_segmenter])
|
||||
|
@ -141,7 +136,8 @@ def translate_new(request):
|
|||
batch_size=30,
|
||||
attn_debug=False,
|
||||
partial = toquotapos(L2),
|
||||
dymax_len = n_suggestions,
|
||||
dymax_len = n_words,
|
||||
n_best = n_best_partial
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -290,7 +290,8 @@ class Translator(object):
|
|||
phrase_table="",
|
||||
partial=None,
|
||||
partialfcheck=True,
|
||||
dymax_len=None):
|
||||
dymax_len=None,
|
||||
n_best=None):
|
||||
"""Translate content of ``src`` and get gold scores from ``tgt``.
|
||||
|
||||
Args:
|
||||
|
@ -311,6 +312,8 @@ class Translator(object):
|
|||
* attns is a list of attention scores for translation having highest cumilative log likelihood
|
||||
"""
|
||||
self.dymax_len = dymax_len
|
||||
if n_best and n_best <= 5:
|
||||
self.n_best = n_best
|
||||
self.partialf = None
|
||||
self.partialfcheck = partialfcheck
|
||||
|
||||
|
|
|
@ -882,7 +882,8 @@ $(document).ready(function() {
|
|||
'langspec': langspec,
|
||||
'sentence': hin_inp.text(), // Maybe use some good names here?
|
||||
'partial_trans': partial.clone().children().remove().end().text(),
|
||||
'n_words': 2
|
||||
'n_words': 2,
|
||||
'n_best_partial': 5,
|
||||
}, function(data) {
|
||||
// console.log(data)
|
||||
parseProcessedJsonResultsfunction(data, globalPartial)
|
||||
|
|
Загрузка…
Ссылка в новой задаче