func convert_sentence()

in TextClassificationOnMobile/iOS/TextClassificationStep2/TextClassificationStep2/ViewController.swift [80:107]


    func convert_sentence(sentence: String) -> [Int32]{
            // This func will split a sentence into individual words, while stripping punctuation
            // and will then evaluate each words against stopwords. If it's in the stop words
            // the word will be ignored. If it isn't in the stopwords, then the word will be looked for
            // in the dictionary. If it's there, it's value from the dictionary will be added to
            // the sequence. Otherwise we'll continue
            
            // Initialize the sequence to be all 0s, and the length to be determined
            // by the const SEQUENCE_LENGTH. This should be the same length as the
            // sequences that the model was trained for
            var sequence = [Int32](repeating: 0, count: SEQUENCE_LENGTH)
            
            var words : [String] = []
            sentence.enumerateSubstrings(in: sentence.startIndex..<sentence.endIndex,options: .byWords) {
                                           (substring, _, _, _) -> () in words.append(substring!) }
            var thisWord = 0
            for word in words{
                if (thisWord>=SEQUENCE_LENGTH){
                    break
                }
                let seekword = word.lowercased()
                if let val = words_dictionary[seekword]{
                    sequence[thisWord]=Int32(val)
                    thisWord = thisWord + 1
                }
            }
            return sequence
        }