567eb21f9cb4ea21d36104c58244805073b9908d,tgen/lexicalize.py,KenLMFormSelect,get_surface_form,#KenLMFormSelect#Any#Any#Any#,108
Before Change
best_score = score
best_form_idx = form_idx
if self._sample:
probs = np.exp(scores) / np.sum(np.exp(scores)) // softmax
return np.random.choice(possible_forms, p=probs)
return possible_forms[best_form_idx]
After Change
self._lm.BaseScore(state, sentence[idx].encode("utf-8"), state)
best_form_idx = 0
best_score = float("-inf")
scores = []
for form_idx, possible_form in enumerate(possible_forms):
possible_form = possible_form.lower().replace(" ", "^").encode("utf-8")
score = self._lm.BaseScore(state, possible_form, dummy_state)
scores.append(score)
if score > best_score:
best_score = score
best_form_idx = form_idx
if self._sample:
probs = softmax(scores)
return np.random.choice(possible_forms, p=probs)
return possible_forms[best_form_idx]
def load_model(self, model_fname_pattern):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 7
Instances
Project Name: UFAL-DSG/tgen
Commit Name: 567eb21f9cb4ea21d36104c58244805073b9908d
Time: 2016-10-10
Author: odusek@ufal.mff.cuni.cz
File Name: tgen/lexicalize.py
Class Name: KenLMFormSelect
Method Name: get_surface_form
Project Name: UFAL-DSG/tgen
Commit Name: 567eb21f9cb4ea21d36104c58244805073b9908d
Time: 2016-10-10
Author: odusek@ufal.mff.cuni.cz
File Name: tgen/lexicalize.py
Class Name: FrequencyFormSelect
Method Name: get_surface_form
Project Name: UFAL-DSG/tgen
Commit Name: 567eb21f9cb4ea21d36104c58244805073b9908d
Time: 2016-10-10
Author: odusek@ufal.mff.cuni.cz
File Name: tgen/lexicalize.py
Class Name: RNNLMFormSelect
Method Name: get_surface_form