[WSG20] Programming Fundamentals Week 1

Daily Challenge (May 5): Make an interactive version of the visualization from the previous day that allows your reader to explore the data–select and compare various features against each other. (Explore a bit yourself and select a few meaningful properties for the list of choices you’d like to offer your reader; don’t include ALL the entity properties of the Movie entity).

1 Like
3 Likes

Looking at the coding on this page for the daily challenge from yesterday, many of these things are far more advanced than what was covered in the first lecture yesterday. I think these long pieces of code can bamboozle people, it certainly does for me.

I feel like we went from fairly basic concepts to the multiple lines of code very quickly. For me there needs to be a bit more of a smooth transition.

1 Like

Hi Colin,
Yes - does seem like a lot of code. But this was also meant to be a fun challenge to encourage people to experiment. The simplest version of the solution would be what @Valeriu Ungureanu or @Regina Cervantes posted above:

DateListPlot[EntityClass["Movie", "StarWarsFranchise"]
  [{EntityProperty["Movie", "ReleaseDate"], 
   EntityProperty["Movie", "ProductionBudget"]}]]

For this week we are focusing on “Practical Programming” - things we feel many people would like to be able to use in day-to-day work - import data, visualize it, or build an interface to explore data. Maybe look at the code this week as a showcase of examples and then in the next three weeks we will pick up again with more fundamental aspects of programming in WL.
Thanks.

1 Like

Good point.

So the the entities are part of the continuously updated Wolfram Knowledgebase also used in Wolfram|Alpha. Here are some of the data sources used for the knowledgebase: Source—Wolfram Documentation

You’ll find more information about each entity on its associated documentation page. For e.g. Movie—Wolfram Documentation. The curated data can be a result of pulling in information from multiple sources and the specifics of the curation process are not usually included.

Meanwhile for the datasets on the Wolfram Data Repository you will find the “Source Metadata” at the bottom of each data resource that gives you more detailed information.

A simple snippet to get you started:

Manipulate[
 ImageResize[movie["Image"], Medium], 
 {movie, EntityList[EntityClass["Movie", "StarWarsFranchise"]]}]

I can make a collage of the leading actors of each movie.

Here’s the code for ten actors (based on Abrita’s code):

Manipulate[
ImageCollage[PersonData[movie[“Cast”][[Range[10]]], “Image”]],

{movie, EntityList[EntityClass[“Movie”, “StarWarsFranchise”]]}
]

That results in:

2 Likes

Bare Bones Star Wars Manipulation

1 Like
1 Like

A desktop version of the previous post:

Manipulate[
 Column[{Row[{Column[{Style["Release Title:", color], 
       EntityList[EntityClass["Movie", "StarWarsFranchise"]][[
        releaseNumber]]}], "  ",
     Column[{Style["Director:", color], 
       EntityList[EntityClass["Movie", "StarWarsFranchise"]][[
          releaseNumber]][EntityProperty["Movie", "Director"]][[1]]}],
      "   ",
     Column[{Style["Producer:", color], 
       EntityList[EntityClass["Movie", "StarWarsFranchise"]][[
          releaseNumber]][EntityProperty["Movie", "Producers"]][[1]]}],
     "   ",
     Column[{Style["Production Budgent:", color], 
       EntityClass["Movie", "StarWarsFranchise"][
         EntityProperty["Movie", "ProductionBudget"]][[
        releaseNumber]]}]}],
   Style["Cast and Roles:", color], 
   Grid@Partition[
     Column /@ 
      Transpose[{Keys[
         EntityList[EntityClass["Movie", "StarWarsFranchise"]][[
           releaseNumber]][EntityProperty["Movie", "CastAndRoles"]]], 
        First /@ 
         Values[EntityList[
             EntityClass["Movie", "StarWarsFranchise"]][[
            releaseNumber]][
           EntityProperty["Movie", "CastAndRoles"]]]}], 4]}],
 {releaseNumber, Range@10, ControlType -> Setter}, {releaseNumber, 
  Range@10, Slider}, {color, Purple}]

2 Likes

[WSG20] Programming Fundamentals Week 1

Challenge.nb (452 KB)

1 Like

Hi!
Is it possible to watch the earlier lessons from this week?
Thanks,
Garfield

Yes, absolutely. We’ll send all the relevant links (to the videos and the download locations for the notebooks) in a consolidated email at the end of the week to all the registered attendees.

Daily Challenge (Day 3): Give “Pig Latin” a shot https://challenges.wolfram.com/challenge/pig-latin

1 Like

We didn’t get to patterns on Thrusday. We’ll look at them tomorrow and then get back to the challenge.

Here is a class that can be used to get the inflation-adjusted values of production budget at a single valuation date so the resulting comparison is fair:

Now after extracting and massaging the data from this class it can be visualized and compared on a DateHistogram:

Here is a comparison using the value of the dollar, based on Today:

Here is a comparison using the value of the dollar at the time of the release of Mathematica:

My god, the dollar has lost 55% of its value in the past 31 years!

3 Likes

I feel like we are wrapping layer after layer, forming a snowball of code that I hope doesn’t melt. This is “brakety” and “wrappery” hence I get lost in the brackets and can’t visualize what is happening underneath very well. Having said that I find all this valuable and instructive!

1 Like

Hi Abrita,

To initiate the challenge, let’s start with the following code:

PigLatin[text_String] := 
 Block[{vowels = {"a", "e", "i", "o", "u"}, consonants},
  consonants = Complement[Alphabet[], vowels];
  consonants = Join[consonants, ToUpperCase@consonants];
  StringReplace[text,
   {
    x__ /; 
      StringMatchQ[x, 
       Flatten[{consonants, ToUpperCase@vowels}] .. ~~ vowels ~~ 
        LetterCharacter ...] :> 
     StringTake[x, StringPosition[x, vowels][[1, 1]] ;; -1] <> 
      StringTake[x, StringPosition[x, vowels][[1, 1]] - 1] <> "ay",
    x__ /; 
      StringMatchQ[x, 
       Flatten@{consonants, ToUpperCase[Alphabet[]]} ~~ 
        LetterCharacter ...] :> x,
    x__ /; StringMatchQ[x, vowels ~~ LetterCharacter ...] :> x <> "way"
    }
   ]
  ]
2 Likes