Skip to content

Instantly share code, notes, and snippets.

@Lily-La-Day
Last active September 9, 2019 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lily-La-Day/7de81053e0f0fe1b7fdb58b5811619fc to your computer and use it in GitHub Desktop.
Save Lily-La-Day/7de81053e0f0fe1b7fdb58b5811619fc to your computer and use it in GitHub Desktop.

Letter To Cover Letter

Overview

Your letter can be turned into a cover letter here: https://lily-la-day.github.io/day-one/ (sort of)

How to Use

  • Either:
  • Write your cover letter directly into the text area
  • Certain words will automatically be replaced with more appropriate ones. or:
  • Paste your cover letter into the text area
  • Click CV-ify and your letter will be magically "professionalised"
  • *Your vocabulary will automatically be updated to sound more CV like.

Technologies Used : HTML5/CSS3/Vanilla JS

The Process

The Plan

When I originally had the idea to create this nifty piece of technology I envisioned using the Words API (see here for API info and documentation: https://www.wordsapi.com/docs/) as an automatic "professional synonym generator" and initially tried to implement this.

The plan was quite ambitious in that I ultimately wanted to make one and possibly two AJAX requests for each word typed. One to determine "part of speech" (so noun/adjective/verb etc) and one to then find a synonym for the word depending on this word type.

This was my first attempt at using an axios request to get the part of speech and then passing the result to a function that took the word and replaced it with a more professional one.

  const getWordType = (text) => {
  
  //request to find word type

     axios.get(`https://wordsapiv1.p.mashape.com/words/${text}`,  {

       headers: { 'X-Mashape-Key': token }
    })
      .then((res) => {
        const partOfSpeech = res.data.results[0].partOfSpeech
//function to chnage word 
         changeWord(text, partOfSpeech)
      })
      .catch((err => console.log(err)))
  }

I quickly decided that it would be easier to create an array of my own "professional synonyms" as there was no way to guarantee a randomly selected synonym generated by the API would be appropriate given the context, I originally made an array of objects with "word" and "part of speech" keys. And my changeWord function looked like this:

const changeWord = (text, partOfSpeech) => {
    const old = document.querySelector(`[class*="-${text}"]`)

     let newWord = ''
    if (partOfSpeech === 'adjective') {

       newWord = jargon[4].word

     } else if (partOfSpeech === 'adjective') {

       newWord = jargon[6].word

     } else newWord = jargon[8].word
    ed.innerText = newWord
    old.innerText = newWord + ' '
    makeArray(newWord)
    ```
    
 This implementation worked to a certain extent and by triggering the function on space bar keydown I was able to select and generate new words. I quickly found though that the API was not reliable or useful enough in this context  to justify the repeated requests and decided to rethink entirely. 
 
 
 
 Instead I decided to do the work myself and created a function that would do its best to detect word type based on the word ending and replace appropriately. I then created arrays of words that would in theory work as replacements (but sound much more professional obviously). 
 

 
 Part of the function implemented: 
 
 ```js 
 if (joined === 'ing') {

      newWord = ingWords[Math.floor(Math.random() * 6)]

    }

And the array of appropriate synonyms:

const ingWords = [ 'striving for', 'motivating', 'executing', 'establishing', 'launching', 'implementing']

What is unfinished and what do I need to improve?

There is lots left to work on here and it is far from finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment