![]() I mapped over this array and used an IF statement. To find these words, I took the sentences and split them into an arary of words. It would be bad if ‘apply’ or ‘Italy’ were tagged as adverbs. To find an adverb, Hemingway just finds words that end in ‘ly’ and then checks that it isn’t on a list of non-adverb ‘ly’ words. The next thing I decided to tackle was the adverbs. With this done, I had a partially working product. let cleanSentence = sent.replace(//gi, “”) + “.” After some Googling I found a much more elegant solution. Although I don’t have much experience using regex, I knew that it would be the best solution. Whist it worked, I searched for a better solution. I used split(‘symbol’) and join(‘’) to remove the punctuation and then appended ‘.’ onto the end. My first solution was very primitive but it worked. The numbers of letters in the sentence included the commas, dashes, colons and semi-colons.Eliminate very-hard-to-read sentences and minimize hard-to-read sentences. When I split the paragraphs into sentences, I had removed all of the full stops. Check reading levels with the Hemingway Editor. Once the sentences have been returned, I join them all together to make each of the paragraphs.Īt this point, I realised that there were a few problems in my code. I took the exact colours from the Hemingway app. The CSS file is really simple it just has each of the classes (adverb, passive, hardSentence) and sets their background colour. This is how I’m going to define the highlighting. I used template strings again but include a class in the span tags. This code says that if a sentence is longer than 14 words and has a level of 10 to 14 then its hard, if its longer than 14 words and has a level of 14 or up then its very hard. The start of the file contained immediately invoked function expressions. I started to look through the file for anything that I could make sense of. This changes a 3-line file into a 4859-line file with everything formatted nicely. To solve this, I copied the file into VS Code and formatted the document ( Control+ Shift + I for VS Code). This code is in a minified form, which is a pain to read and understand. Minified file on the top, Formatted file on the bottom. There, I found the file I was looking for: hemingwa圓-web.js. Opening developer tools in Chrome ( Control + Shift + I or F12 on Windows/Linux, Command + Option + I on Mac) and navigating to Sources provided the answers. It could have sent the text to a server to calculate the complexity of the writing, but I expected it to be calculated client side. I had no idea how the app worked when I first started. So I needed to find out how Hemingway worked! A screenshot of the Hemingway Editor Getting the Logic I came up with the idea of integrating a Hemingway style editor into a markdown editor. At the same time I’ve been trying to find ideas for small projects. I’ve been using the Hemingway App to try to improve my posts.
0 Comments
Leave a Reply. |