-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.py
More file actions
71 lines (47 loc) · 1.69 KB
/
strings.py
File metadata and controls
71 lines (47 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
strings.py
There's four activities in the assignment, each with a set of text or words to work with.
"""
def add_prefix_un(word):
"""
:param word: str of a root word
:return: str of root word with un prefix
This function takes `word` as a parameter and
returns a new word with an 'un' prefix.
"""
return "un" + word
def make_word_groups(vocab_words):
"""
:param vocab_words: list of vocabulary words with a prefix.
:return: str of prefix followed by vocabulary words with
prefix applied, separated by ' :: '.
This function takes a `vocab_words` list and returns a string
with the prefix and the words with prefix applied, separated
by ' :: '.
"""
prefix = ' :: ' + vocab_words[0]
return prefix.join(vocab_words)
def remove_suffix_ness(word):
"""
:param word: str of word to remove suffix from.
:return: str of word with suffix removed & spelling adjusted.
This function takes in a word and returns the base word with `ness` removed.
"""
word = word[:-4]
if word[-1] == "i":
word = word[:-1] + "y"
return word
def adjective_to_verb(sentence, index):
"""
:param sentence: str that uses the word in sentence
:param index: index of the word to remove and transform
:return: str word that changes the extracted adjective to a verb.
A function takes a `sentence` using the
vocabulary word, and the `index` of the word once that sentence
is split apart. The function should return the extracted
adjective as a verb.
"""
sentence = sentence.split()[index]
if sentence[-1] == ".":
sentence = sentence[:-1]
return sentence + 'en'