         assert(keys.count == touchTimestamps.count)
         print(keys.count)
         if hasAssessedEmotion {
-            if let sentence = textDocumentProxy.documentContextBeforeInput?.components(separatedBy: " ") {
+			if let sentence = textDocumentProxy.documentContextBeforeInput?.components(separatedBy: CharacterSet(charactersIn: " \n")) {
                 print ("sentence in view did disppear is", sentence)
                 sentiment = getSentiment(wordArr: sentence)
                 for (key, touchTimestamp) in zip(keys, touchTimestamps) {
-                    let components = key.components(separatedBy: " ")
+					
                     var keyEvent: KeyEvent!
-                    switch components.count {
-                    case 1:
-                        keyEvent = SymbolKeyEvent()
-                        (keyEvent as! SymbolKeyEvent).key = key
-                        break
-                    case 2:
-                        keyEvent = BackspaceKeyEvent()
-                        (keyEvent as! BackspaceKeyEvent).numberOfDeletions = Int(components[1])!
-                    default:
-                        break
-                    }
+					
+					if key.characters.count == 1 {
+						keyEvent = SymbolKeyEvent()
+						(keyEvent as! SymbolKeyEvent).key = key
+					} else {
+						let components = key.components(separatedBy: " ")
+						keyEvent = BackspaceKeyEvent()
+						(keyEvent as! BackspaceKeyEvent).numberOfDeletions = Int(components[1])!
+					}
                     
                     keyEvent.downTime = touchTimestamp.down
                     keyEvent.upTime = touchTimestamp.up

    }
	
	private func getSuggestedWords() -> (completions: [String], gussess: [String])? {
		let textChecker = UITextChecker()
		let range = NSRange(location: 0, length: currentWord.characters.count)
		let completions: [String] = textChecker.completions(forPartialWordRange: range, in: currentWord, language: "en_US")!

	
	private func updateAutoCorrectionSelector() {
		if currentWord == "" {
			self.autoCorrectionSelector.updateButtonArray(words: [])
		}
		else if let completions = getSuggestedWords()?.completions.filter({ $0 != currentWord }) {
			var partialGuesses: [String]
			if completions.count < 2 {
				partialGuesses = ["\"" + currentWord + "\""] + completions
