Message Boards Message Boards

GROUPS:

[WSG20] Multiparadigm Tools and Applications (EIWL Days 14, 15, 16, 17)

Posted 1 month ago
381 Views
|
13 Replies
|
9 Total Likes
|

During week two of the Wolfram Study Group Apr 2020 (WSG20) we are looking at the following topics from Stephen Wolfram's book Elementary Introduction to the Wolfram Language:

Day 14: Chapter 12 - Sound, Chapter 17 - Units, Chapter 19 - Dates and Times

Day 15: Chapter 42 - String Patterns and Templates, Chapter 18 - Geocomputation, Chapter 21 - Graphs and Networks

Day 16: Chapter 22 - Machine Learning

Day 17: Chapter 36 - Creating Websites and Apps, Chapter - 43 Storing Things

We are looking at videos from the Wolfram U interactive course on EIWL and also working on simple exercises and mini projects.

Feel free to post questions on the material we covered in these sessions here.

13 Replies

Daily Challenge (Day 14): Back to EIWL - Generate graphics for a path obtained by turning 0°, 1°, 2°, ... , 180°. (After every turn you can move forward by a random integer number of units ~~mm~~ ).

Unfortunately, Graphics[] doesn't accept Quantity[1, "Millimeters"]:

Graphics@Line@
AnglePath[{RandomInteger@#, # \[Degree]} & /@ Range[0, 180]]

enter image description here

Agreed. Moving forward by a random integer number of steps should be just fine. Or for fun - use a control object to set the number of steps to move.

Posted 1 month ago

Using a control to specify the maximum step size.

Manipulate[
 Graphics@Line@
   AnglePath[{RandomInteger[{1, maxStep}], # \[Degree]} & /@ Range[0, 180]], 
 {maxStep, 1, 50, 1}]

A simple modification of the precedent code gives another interesting result:

Graphics@Line@AnglePath[{1 + (-1)^#, # \[Degree]} & /@ Range[0, 720]]

enter image description here

Pretty neat - isn't it?

Another example:

Graphics@Line@
  AnglePath[{Quotient[#, 2], # \[Degree]} & /@ Range[0, 11959]]

enter image description here

Here's another one:

Manipulate[Graphics[Line[AnglePath[{# \[Degree], s} & /@ Range[0, 180]]]], {s, 1, 50}]

Daily Challenge (Day 15): From: https://www.mathematica-journal.com/2013/04/30/strings/ Section 9.4, Exercise 6.

A common task in transcribing audio is cleaning up text, removing certain phrases such as um, er, and so on, and other tags that are used to make a note of some sort. For example, the following transcription of a lecture from the University of Warwick, Centre for Applied Linguistics (BASE Corpus [10]), contains quite a few fragments that should be removed, including newline characters, parenthetical remarks, and nonwords. Use StringReplace with the appropriate rules to “clean” this text and then apply your code to a larger corpus.

enter image description here

Let's define the function cleanText[]:

cleanText[text_String] := 
 StringReplace[
  text, {Whitespace ~~ "er" | "um" | "s-," ~~ Whitespace :> " ", 
   Whitespace ~~ "\n" :> " ", 
   Whitespace ~~ "[" ~~ ___ ~~ "]" ~~ Whitespace :> " "}]

and let's apply it on the audio transcription sample:

In[2]:= cleanText@"okay well er today we're er going to be carrying \
on with the er French \nRevolution you may have noticed i was sort of \
getting rather er enthusiastic \nand carried away at the end of the \
last one i was sort of almost er like i sort \nof started at the \
beginning about someone standing on a coffee table and s-, \nshouting \
to arms let's storm the Rootes Social Building [laughter] or er let's \
go \nout arm in arm singing the Marseillaise or something er like that"

Out[2]= "okay well today we're going to be carrying on with the \
French Revolution you may have noticed i was sort of getting rather \
enthusiastic and carried away at the end of the last one i was sort \
of almost like i sort of started at the beginning about someone \
standing on a coffee table and shouting to arms let's storm the \
Rootes Social Building or let's go out arm in arm singing the \
Marseillaise or something like that"

Daily challenge (Day 16): From EIWL chapter 22

Generate a list of 10 random numbers from 0 to 10, and make a graph of the 3 nearest neighbors of each one.

Posted 1 month ago
SeedRandom[314]; data = RandomInteger[{0, 10}, 10];

nnGraph = data //
  NearestNeighborGraph[#, 3,
    VertexLabels -> "Name",
    VertexSize -> 0.2,
    VertexShapeFunction -> "RoundedSquare"] &

enter image description here

nnGraph // CommunityGraphPlot

enter image description here

Daily Challenge (Day 17): Post a link to a fun web app/microsite you created with CloudDeploy or CloudPublish and also include the code you used to create it.

The first offering of the Daily Study Group ends today. Hope you enjoyed it as much as we did bringing it to you. A new session starts on Monday, May 4. Sign up on Wolfram U

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract