MCPcopy Create free account
hub / github.com/NsLearning/LangHelper / Helper_SplitIntoSentences

Function Helper_SplitIntoSentences

ChatGPT/src-tauri/src/scripts/chat.js:541–577  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

539}
540// Split the text into sentences so the speech synthesis can start speaking as soon as possible
541function Helper_SplitIntoSentences(text) {
542 var sentences = [];
543 var currentSentence = "";
544
545 for(var i=0; i<text.length; i++) {
546 //
547 var currentChar = text[i];
548
549 // Add character to current sentence
550 currentSentence += currentChar;
551
552 // is the current character a delimiter? if so, add current part to array and clear
553 if (
554 // Latin punctuation
555 currentChar == ','
556 || currentChar == ':'
557 || currentChar == '.'
558 || currentChar == '!'
559 || currentChar == '?'
560 || currentChar == ';'
561 || currentChar == '…'
562 // Chinese/japanese punctuation
563 || currentChar == '、'
564 || currentChar == ','
565 || currentChar == '。'
566 || currentChar == '.'
567 || currentChar == '!'
568 || currentChar == '?'
569 || currentChar == ';'
570 || currentChar == ':'
571 ) {
572 if (currentSentence.trim() != "") sentences.push(currentSentence.trim());
573 currentSentence = "";
574 }
575 }
576 return sentences;
577}
578
579function copyToClipboard(text, btn) {
580 window.clearTimeout(window.__cpTimeout);

Callers 1

Helper_CheckNewMessagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected