File size: 1,055 Bytes
ab75c71
1e2c870
 
 
 
 
 
 
 
 
 
 
 
ab75c71
1e2c870
 
 
 
69bdd1b
1e2c870
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { defaultActionnables } from "./defaultActionnables"
import { lightSourceNames } from "./lightSourceNames"

export function normalizeActionnables(rawActionnables: string[]) {

  const tmp = rawActionnables.map(item =>
    // clean the words to remove any punctuation
    item.replace(/\W/g, '').trim()
  )

  const deduplicated = new Set<string>([
    ...tmp,
    // in case result is too small, we add a reserve of useful words here
    ...defaultActionnables,
    // but we still only want 10 here
    ].slice(0, 10)
  )

  // console.log("deduplicated:", deduplicated)

  let actionnables = Array.from(deduplicated.values())

  // if we are missing a light source, we add one (the generic "light")
  if (!actionnables.some(actionnable => lightSourceNames.includes(actionnable))) {
    actionnables.push("light")
  }

  // if ground surfaces aren't in the list, we add at least one (the most generic)
  // if (!actionnables.includes("floor") || !actionnables.includes("ground")) {
  //   actionnables.push("floor")
  // }

  return actionnables
}