Note that there are some explanatory texts on larger screens.

plurals
  1. PORecognizing Spaces in text
    text
    copied!<p>I'm writing a program that deciphers sentences, syllables, and words given in a basic text file.</p> <p>The program cycles through the file character by character. It first looks if it is some kind of end-of-sentence marker, like <code>!</code> <code>?</code> <code>:</code> <code>;</code> or <code>.</code>. Then if the character is not a space or tab, it assumes it is a character. Finally, it identifies that if it is a space or tab, and the last character before it was a valid letter/character (e.g. not an end-of-sentence marker), it is a word.</p> <p>I was a bit light on the details, but here is the problem I have. My word count is equal to my sentence count. What this interprets to, is it realizes that a word stops when there is an end of sentence marker, BUT the real problem is the spaces are considered valid letters. </p> <p>Heres my if statement, to decide if the character in question is a valid letter in a word:</p> <pre><code>else if(character != ' ' || character != '\t') </code></pre> <p>I've already ruled out end-of-sentence markers by that point in the program. (In the original if actually). From reading off an Ascii table, 32 should be the space character. However, when i output all of the characters that make it into that block of code, spaces are in there.</p> <p>So what am I doing wrong? How can i stop spaces from getting through this if?</p> <p>Thanks in advance, and I have a feeling the question may be a bit vague, or poorly worded. If you have any questions or need clarification, let me know. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload