mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-01 21:15:15 +08:00
added ! and ? as sentence stops
This commit is contained in:
parent
27953fbb1d
commit
826cb257e2
1 changed files with 10 additions and 3 deletions
|
|
@ -108,13 +108,20 @@ function buildSentences() {
|
|||
let returnList = [];
|
||||
$.each(wordsList, (index, word) => {
|
||||
let previousWord = returnList[index - 1];
|
||||
if (index == 0 || getLastChar(previousWord) == ".") {
|
||||
if (index == 0 || getLastChar(previousWord) == "." || getLastChar(previousWord) == "?" || getLastChar(previousWord) == "!") {
|
||||
//always capitalise the first word or if there was a dot
|
||||
word = capitalizeFirstLetter(word);
|
||||
} else if (
|
||||
//10% chance to add a dot or if its a last word
|
||||
//10% chance to end a sentence
|
||||
(Math.random() < 0.1 && getLastChar(previousWord) != "." && index != wordsList.length - 2) || index == wordsList.length - 1) {
|
||||
word += ".";
|
||||
let rand = Math.random();
|
||||
if (rand <= 0.8) {
|
||||
word += ".";
|
||||
} else if (rand > .8 && rand < .9){
|
||||
word += "?";
|
||||
} else {
|
||||
word += "!";
|
||||
}
|
||||
} else if (Math.random() < 0.01 &&
|
||||
getLastChar(previousWord) != "," &&
|
||||
getLastChar(previousWord) != ".") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue