Guest User

Untitled

a guest
Mar 18th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. const describePostTexts = texts => {
  2. const postTitle = texts[0]
  3. const postIntro = texts.slice(1, 4).join('.\n')
  4. const intro = `The post is titled "${postTitle}" and it reads as it follows:\n`
  5. return intro + postIntro
  6. }
  7.  
  8. const describeEntityCounts = counts => {
  9. const top = counts[0]
  10. const intro = `We find a total of ${counts.length} entities mentioned. `
  11. const topCount = `Mainly "${top.name}" which appears ${top.count} times, followed by `
  12. const topCounts = counts.slice(1, 4).map(({name, count}) => `"${name}" mentioned ${count} times`).join(', ')
  13. const rest = counts.slice(4, 7).map(({name}) => name).join(', ')
  14. const others = `. Some other mentions include ${rest} plus many others`
  15. return intro + topCount + topCounts + others
  16. }
  17.  
  18. const describeTypesCounts = counts => {
  19. const intro = `Regarding the types of entities, it includes `
  20. const other = counts.find(({name}) => name = 'OTHER')
  21. const noOther = counts.filter(({name}) => name != 'OTHER')
  22. const body = noOther.map(({name, count}) => `${count} ${plural(cleanName(name), count)}`).join(', ')
  23. const closing = `, and also some other ${other.count} things`
  24. return intro + body + closing
  25. }
Add Comment
Please, Sign In to add comment