(sentence)
| 41 | # as a string and converts it into an array of words and then associates a |
| 42 | # feature vector with each word. |
| 43 | def sentence_to_vectors(sentence): |
| 44 | # Create an empty array of vectors |
| 45 | vects = dlib.vectors() |
| 46 | for word in sentence.split(): |
| 47 | # Our vectors are very simple 1-dimensional vectors. The value of the |
| 48 | # single feature is 1 if the first letter of the word is capitalized and |
| 49 | # 0 otherwise. |
| 50 | if word[0].isupper(): |
| 51 | vects.append(dlib.vector([1])) |
| 52 | else: |
| 53 | vects.append(dlib.vector([0])) |
| 54 | return vects |
| 55 | |
| 56 | |
| 57 | # Dlib also supports the use of a sparse vector representation. This is more |
no test coverage detected