/ai-zootson

Artificial Intelligence course programming exercise

Primary LanguageClojureMIT LicenseMIT

ai-zootson

Artificial Intelligence course programming excercise.

Running

To run main program (read inputs, read questions, write answers.txt):

lein run

To run tests:

lein midje :autotest

Requirements

  • Read facts from two csv files
  • Read facts given as English sentences
    • "Cheetah is the fastest land animal."
    • "The kiwi is a national symbol of New Zealand."
  • Read questions given as English sentences
    • "Are girls slower than a cheetah?" => "Yes" (because Cheetah is the fastest land animal)
    • "Mention an animal that is a national symbol." => "Kiwi"
  • Answer questions using known facts
  • NLP libraries (NLTK etc.) and 3rd party word lists forbidden

Implementation

  • Clojure
  • Uses Core.logic for fact storage and logical queries
  • Processes sentences using BNF
    • Separate BNF language for facts and questions
    • Instaparse
  • Midje for tests

Possible improvements

  • Large part of logical queries on questions.clj was written in hurry, could use refactoring
  • Core.logic might be unnecessary, it might be simpler to store facts as vector of maps and find matching facts manually
  • Refactor fact-language to tag different parts of sentences like question-language does
    • That way it would be easier to turn parse results into facts