Quick-start deCheemQL Example

Often we come across situations where there are many rules, restrictions and facts that we need to compare with each other in order to. That is where deCheem comes into play.

Each deCheemQL statement consists only of 4 simple parts:

  1. Statement type - this starts off the sentence and can be either ‘LET’, ‘IF’, ‘ELIF’ or ‘ASK’
  2. Subject phrases - the adjectives that describe a subject are typed out (separated by commas), and enclosed in brackets. Multiple subjects can be stringed together by ‘and’ (e.g. (is_apple,is_green) and (is_orange,is_yellow_red) ). Negate an adjective by prepending a ‘!’ sign.
  3. The ‘be’ word - this is to indicate the preceding subjects ‘being’ the modal phrases after that
  4. Modal phrases- these are similar to subject phrases, but indicate whether a set of adjectives are always, never or possibly true. Preceed every phrase with either ‘Always’, ‘Never’ or ‘Possibly’.

deCheemQL is basically YAML with some deCheemQL specifics. Each statement is started off with a ‘- case’ line header, followed by the deCheemQL statement: .. code-block:: yaml

  • case: LET (is_apple) and (is_orange) be Always(sweet,delicious) and Never(smelly,spicy)

Conditional statements like ‘IF’ and ‘ELIF’ can have a child ‘then’ statement under it, and can be nested as many layers as you need, in any order or combination you like.

then:
- SECTION_HEADER: &statements # We use '&' to denote a YAML anchor, which Sublime Text recognises as a symbol and thus useful for toggling between sections of the statements with 'Command+R'.
- case: LET (is_apple) and (is_orange) be Always(sweet,delicious) and Never(smelly,spicy)
- case: IF (is_apple) be Never(sour)
  - case: LET (is_cake) be Always (tarty,creamy)
- case: ELIF (is_apple) be Never(smelly,spicy) #Needs to be preceded by a IF or ELIF case at the same level just before
  then:
  - case: LET (is_desert) be Always (raining,thundering)
- case: ASK (is_sky)
- case: ASK (is_cake)

Test it out yourself!

The easiest way to get started is to use Sublime Text as your YAML editor, and using the RESTer package to send HTTP requests to the free and open deCheem processor endpoint right from your editor!

Simply copy-paste the example below into Sublime Text and execute the entire file with the RESTer: HTTP Request command. The results will then be displayed in a tab right next to the input file.

POST http://gmkung.pythonanywhere.com/yaml/
@response_group: 1
@response_group_clean: true
@request_focus: true

---
apiVersion: deCheem4.0
verboseResults: false
responseFormat: yaml

then:
#Let this be the situation.
- case: LET (is_human_right) be Always(necessary)

#If he says ...
- case: IF (is_human_right) be Always (necessary) and Possibly (compromised)
  then:
  - case: LET (is_military_action) be Always(justified) and Possibly (!state_financed)
  - case: LET (is_human_right) be Always (derived_from_religion)

# and she says ...
- case: IF (is_human_right) be Possibly (derived_from_religion)
  then:
  - case: IF (god) be Possibly (existent)
    then:
    - case: LET (is_religion) be Always (state_financed)

# and I say ...
- case: IF (state_financed) be Possibly(!existent) and Possibly (!holy)
  then:
  - case: LET (is_citizen) be Never (tax_paying)

# ... then let us find out what we all say about the citizen, military action, religion and is_human_rights
# based on the assumption that human rights are necessary
- case: ASK (is_citizen)
- case: ASK (is_military_action)
- case: ASK (is_religion)
- case: ASK (is_human_right)

The YAML response that comes back will tell you what it means to be a ‘sky’ or ‘cake’ based on the beliefs in this set:

- collectionName: DefaultCollection
  consequenceResults:
  - then: []
  - then:
    - then: []
  - then: []
  - newTotalBoundary: {is_citizen: true, tax_paying: false}
    originalBoundary: {is_citizen: true}
    possible: true
  - newTotalBoundary: {is_military_action: true, justified: true}
    originalBoundary: {is_military_action: true}
    possible: true
  - newTotalBoundary: {is_religion: true, state_financed: true}
    originalBoundary: {is_religion: true}
    possible: true
  - newTotalBoundary: {derived_from_religion: true, is_human_right: true, necessary: true}
    originalBoundary: {is_human_right: true}
    possible: true
  manifestationCollections:
  - collectionName: null
    manifestationCollections: []