I can try my best to explain it.
For the Grammar: So firstly each word is assigned a part of speech based on what part of speech it generally is. Words such as to are assigned as a "preposition" despite the fact that to can technically be used as part of a verb to be. From there it is simply a matter of calculating whether each part of speech was in a valid position. Like a hinted at earlier this system wasn't perfect. I didn't account for if a word was singular or plural, which obviously changes what pronouns and state of being words should be allowed, and as I said some words like to can be different parts of speech based on context. That's why I made the grammar system very forgiving where it needs to flag three or more mistakes before they start to count against you.
For the Scoring: That was way trickier to code since context is so important. Ultimately I gave each noun or verb an either positive or negative value depending on whether it generally has positive or negative connotations: Kicked given a negative value since you normally kick things you don't like. For adjectives, pronouns, and prepositions I gave them a negative value if they negate the word they are associated with Not being the most obvious example. Once that is all decided I multiplied each noun by adjacent adjectives, each verb by adjacent adverbs, and prepositional phrases were calculated separately. Then I added up all the nouns, verbs, and prepositional phrases. This system works about 60% of the time which isn't ideal but it was the best I could figure out.
That's about all there is to it. If I were to continue developing it I would probably redo these systems from the ground up, or find a way to implement a professional grammar checker, since those are not too hard to find on the market.