Code Monkey home page Code Monkey logo

Comments (5)

Linell avatar Linell commented on August 22, 2024

Is this issue intended for adding templates for quirky little sayings? I noticed I got the same "Netflix and Psych" message twice in a row.

from rainjacket.

jacroe avatar jacroe commented on August 22, 2024

Yeah exactly. Right now there's about 20 in total but there's six scenarios in total which leaves about three sayings for each type of day/night. I've been slowly adding to the list, but it's difficult to come up with stuff that works universally.

from rainjacket.

Linell avatar Linell commented on August 22, 2024

Where are these located in the code? Or are they just in your database somewhere? I tried looking through but couldn't find it. I'd love to see how you're deciding which to send and maybe offer up a few contributions for text

from rainjacket.

jacroe avatar jacroe commented on August 22, 2024

They're all in the database. I actually forgot to commit them and my table structures (#16). Until I do, you can view them here.

And here's the logic for choosing a template. This is in data/models/Rainjacket_model.php.

  1. Function getForecast() is called. Latitude, longitude, and a boolean variable representing whether it's day or night gets passed in. The function calls the python scripts with the coordinates as arguments.
  2. The python script returns a bunch of JSON data with a precipitation object, a lookingAhead object, and a temp object. For the templates we only use the precipitation and temp objects.
  3. We now start building our replacement array with the two keys that will always be there: the temperature (temp) and a phrase that describes the day, such as "nice and cozy" or "bloody hot" (tempAdj).
  4. If the precipitation object is not null (that is, there's precipitation of some kind), we add in:
    • topPrecipType - a phrase that describes the heaviest precipitation in terms of intensity and type, e.g. "downpour" or "heavy snow"
    • topPrecipTime - when said precipitation will start
    • topPrecipChance - how likely this precipitation will occur, e.g. "a chance of", "slight chance of".
    • startPrecipType, startPrecipTime, startPrecipChance - the same as it's top- counterparts but instead deals with when the precipitation starts.
    • endPrecipTime - when the precipitation will stop. If it doesn't stop by midnight, this is null.
  5. We then call _getTemplate() and pass in the isDay variable from 1), whether it's going to precipitate, and whether it's going to stop by midnight.
  6. _getTemplate() then scours the database looking for templates that match those three parameters and retuns one at random*
  7. We give the template and replacement array to Smarty and receive the finished forecast.
  • I'd like to expand this to somehow know if a template has been seen by a person before and favor templates that haven't been.

from rainjacket.

jacroe avatar jacroe commented on August 22, 2024

Right so I've finally committed the table structure: rainjacket.sql

from rainjacket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.