import spacy
from spacy.symbols import nsubj

nlp = spacy.load('en')

pronouns = {
	'my' : 'i',
	'your' : 'you',
	'his' : 'he',
	'her' : 'she',
	'its' : 'it',
	'our' : 'we',
	'their' : 'they'
}

articles = ('the', 'a', 'an')

def fixword(word): # articles plurals pronouns fixes one word
	print("word being fixed")
	lowerword = word.lower() # just to be safe

	fixed = ''

	print(word)

	if lowerword in pronouns:
		fixed = pronouns[word]
	elif nlp(lowerword)[0].tag_ in ('NNS', 'NNPS'):
		lemma = nlp(lowerword)[0].lemma_
		fixed= lemma + ' ' + lemma
		print('plurals')
	elif word not in articles:
		fixed = lowerword
	
	print(fixed)
	return fixed

def fixverb(verb): # present, past, and prefixes, returns fixed string
	print("verb being fixed")
	preposition = ''
	fixed = ''

	print(verb.text)
	for child in verb.children:
		if child.tag_ == 'IN':
			preposition = child.text
			break
	if verb.tag_ == 'VBD':
		fixed = 'was ' + preposition + verb.lemma_
	else:
		fixed = 'to ' + preposition + verb.lemma_
	return fixed



def fixpronounciation(word): # uh-ize one word
	print("uhs being fixed for:")
	print(word)
	final = ''

	for x, c in enumerate(word):
		if c in ('a', 'e', 'i', 'o', 'u'):
			final = word[0:x - 1] + '-uh' + word[x:]
			break
	

	return final



# translate function:
# we just need the function to form the order, fixing words, verbs, and the subjects pronounciation


# attempted rewrite but spacy is horrible and it's documentation is horrible, i can't figure out anything.`

# Todo:

# Write translate sentence function