-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopen_file.py
54 lines (35 loc) · 1.13 KB
/
open_file.py
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
__author__ = 'cpalmer'
import os
import sys
current_path = os.path.dirname(os.path.abspath(__file__))
def get_nouns():
list_of_nouns = []
f = open(current_path+"/parts_of_speech/nouns.txt", 'r')
for line in f:
list_of_nouns.append(line)
return list_of_nouns
def get_adjectives():
list_of_adjectives = []
f = open(current_path+"/parts_of_speech/adjectives.txt", 'r')
for line in f:
list_of_adjectives.append(line)
return list_of_adjectives
def get_adverbs():
list_of_adverbs = []
f = open(current_path+"/parts_of_speech/adverbs.txt", 'r')
for line in f:
list_of_adverbs.append(line)
return list_of_adverbs
def get_verbs():
list_of_verbs = []
f = open(current_path+"/parts_of_speech/verbs.txt", 'r')
for line in f:
list_of_verbs.append(line)
return list_of_verbs
def get_file_as_string(filename):
try:
with open(current_path+'/'+filename) as inputFileHandle:
return inputFileHandle.read()
except IOError:
sys.stderr.write("[myScript] - Error: Could not open %s\n" % current_path+'/'+filename)
sys.exit(-1)