Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.4K Views
|
13 Replies
|
9 Total Likes
View groups...
Share
Share this post:

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

13 Replies
Posted 5 years 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

POSTED BY: Rohit Namjoshi

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.

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 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

Here's another one:

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

Another example:

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

enter image description here

Pretty neat - isn't it?

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

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

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 5 years 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}]
POSTED BY: Rohit Namjoshi

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

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

enter image description here

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~~ ).

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