* Better handling of end-of-corpus detection. * Adjusted docstring.pull/71/head
parent
ce0b7217b0
commit
35d030a24e
|
@ -120,6 +120,7 @@ class PromptsFS:
|
|||
|
||||
def get(self, prompt_number: int) -> response:
|
||||
"""Get text from corpus by prompt number.
|
||||
If end of corpus file is reached then '___CORPUS_END___' is returned as phrase.
|
||||
|
||||
Args:
|
||||
prompt_number (int): Number of requested prompt from corpus.
|
||||
|
@ -132,8 +133,9 @@ class PromptsFS:
|
|||
"prompt": self.data[prompt_number],
|
||||
"total_prompt": len(self.data)
|
||||
}
|
||||
return response(True, data=d)
|
||||
except IndexError as e:
|
||||
# TODO: loggin
|
||||
print(e)
|
||||
return None
|
||||
d = {
|
||||
"prompt": "___CORPUS_END___",
|
||||
"total_prompt": 0
|
||||
}
|
||||
return response(True, data=d)
|
||||
|
|
|
@ -131,11 +131,18 @@ class Record extends Component {
|
|||
getPrompt(uuid)
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
this.setState({
|
||||
prompt: res.data.prompt,
|
||||
totalPrompt: res.data.total_prompt
|
||||
});
|
||||
if (res.data.prompt === "___CORPUS_END___") {
|
||||
this.setState({
|
||||
shouldRecord: false,
|
||||
prompt: "*no more phrases in corpus to record*",
|
||||
totalPrompt: res.data.total_prompt
|
||||
})
|
||||
}
|
||||
if (res.success && res.data.prompt !== "___CORPUS_END___") {
|
||||
this.setState({
|
||||
prompt: res.data.prompt,
|
||||
totalPrompt: res.data.total_prompt
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue