petermeissner / crossword.r

An R package to build crosswords
Other
28 stars 3 forks source link

export to json (fit for crosswordjs) #4

Closed petermeissner closed 6 years ago

petermeissner commented 6 years ago

this ...

cw$words
## # A tibble: 16 x 6
##      row   col length direction                           clue     word
##    <int> <int>  <int>     <chr>                         <fctr>    <chr>
##  1    11     1      3     right                 Elongated fish      EEL
##  2     1    11      6      down      Strong swimmer and jumper   SALMON
##  3     3     4      7     right                Largest primate  GORILLA
##  4     2     1      6     right                   Eight legged   SPIDER
##  5     3     2      8      down                Armored reptile TORTOISE
##  6     4     5      6     right Medium-sized omnivorous mammal   JACKAL
##  7    10     1      5     right               Slow but armored    SNAIL
##  8     6     3      8     right            Australian original KANGAROO
##  9     4     5      4      down     Fast runner with long ears     HARE
## 10     8     3      7     right             Living in colonies  TERMITE
## 11    11     5      6     right                      Bait fish   MINNOW
## 12     9     5      6     right        Small, slender predator   WEASEL
## 13    10     8      3     right        Striped but no predator      BEE
## 14     7     3      4     right  clawed and armored sidewalker     CRAB
## 15     5     6      3     right     Tailless humanlike primate      APE
## 16     5     1      2     right    Castrated adult male cattle       OX

... should translate to this ...

 [
          {"y": 11, "x":  1, "orientation": "across", "clue": "Elongated fish", "answer": "EEL"},
          {"y": 1,  "x": 11, "orientation": "down","clue": "Strong swimmer and jumper","answer": "SALMON"},
          {"y": 3,  "x":  4, "orientation": "across","clue": "Largest primate","answer": "GORILLA"},
          {"y": 2,  "x":  1, "orientation": "across","clue": "Eight legged","answer": "SPIDER"},
          {"y": 3,  "x":  2, "orientation": "down","clue": "Armored reptile","answer": "TORTOISE"},
          {"y": 4,  "x":  5, "orientation": "across","clue": "Medium-sized omnivorous mammal","answer": "JACKAL"},
          {"y": 10, "x":  1, "orientation": "across","clue": "Slow but armored","answer": "SNAIL"},
          {"y": 6,  "x":  3, "orientation": "across","clue": "Australian original","answer": "KANGAROO"},
          {"y": 4,  "x":  5, "orientation": "down","clue": "Fast runner with long ears","answer": "HARE"},
          {"y": 8,  "x":  3, "orientation": "across","clue": "Living in colonies","answer": "TERMITE"},
          {"y": 11, "x":  5, "orientation": "across","clue": "Bait fish","answer": "MINNOW"},
          {"y": 9,  "x":  5, "orientation": "across","clue": "Small, slender predator","answer": "WEASEL"},
          {"y": 10, "x":  8, "orientation": "across","clue": "Striped but no predator","answer": "BEE"},
          {"y": 7,  "x":  3, "orientation": "across","clue": "clawed and armored sidewalker","answer": "CRAB"},
          {"y": 5,  "x":  6, "orientation": "across","clue": "Tailless humanlike primate","answer": "APE"},
          {"y": 5,  "x":  1, "orientation": "across","clue": "Castrated adult male cattle","answer": "OX"}
        ]
petermeissner commented 6 years ago

fixed by 792a45aa5543baff439802728c1178a53b925d3a