Search⌘ K
AI Features

Solution: Getting Started

Explore the foundations of using spaCy and Python for natural language processing tasks. This lesson guides you through exercises that demonstrate basic text processing, including counting vowels and reversing the order of words in a sentence. Understand how to manipulate strings efficiently to prepare for more advanced NLP applications.

Exercise 1

Python 3.5
def vowelCount(word):
vowel = ['a','e','i','o','u']
count = 0
word = word.lower()
for x in vowel:
count = count + word.count(x)
return count
print(vowelCount('Gilles De Rais'))

Explanation

  • Line 2: We define the vowel list, which contains the vowels in the English alphabet.

  • Line 3: The word is converted into lowercase using the lower() method.

  • Line 4: The count variable is set to 0. ...