SlideShare a Scribd company logo
Lab 1: Recursion
Introduction
Tracery (tracery.io) is a simple text-expansion language made
by one of your TAs as a
homework assignment for one of Prof. Mateas's previous
courses. It now has tens of
thousands of users, and runs about 7000 chatbots on Twitter
(you never know where a
homework will take you!).
Tracery uses context-free grammars
( https://en.wikipedia.org/wiki/Context-free_grammar) to store
information about how to
expand rules. A Tracery grammar is a set of keys, each of which
has some set of
expansions that can replace it. In our version, the line
"beverage:tea|coffee|cola|milk" means that the symbol
"beverage" can be
replaced with any of those four options. You replace a symbol
whenever you see it in
hashtags. This rule "#name# drank a glass of #beverage#" will
have the "name"
and "beverage" symbols replaced with expansions associated
with those symbols. In
the case of the "beverage" rule above, which has four possible
expansions, one will be
picked at random. If the replacement rule also has hashtags in
it, we replace those, and
if those replacements have hashtags.... we keep replacing things
until all the hashtags
are gone, recursively.
In this assignment, you will be implementing a simplified
version of Tracery in Java, and
then using it to generate generative text. You will also be
writing your own grammar to
generate new texts (hipster cocktails, emoji stories, or nonsense
poems).
Outline
● Compile and run a Java program
● Save all the arguments
● Load the Tracery files
● Output all the rules
● Expand rules and print them to the screen
Compile and run a Java program
This program has several files (Rule.java, and
TraceryRecursion.java). We can't
run these files as code, as we would with other “interpreted”
languages (like Javascript
https://en.wikipedia.org/wiki/Context-free_grammar
or Python). For Java, we need the computer to put them all
together and translate it to
machine code, in a process called “compiling”.
You will compile and run your Java program from the command
line. When you see $,
this means that it is a command that you will enter in the
command line. Windows and
Unix (such as Linux or the Mac terminal) command lines are a
little different, be sure
you know the basics of navigating the one you are using.
Do you have Java installed on your machine? What version?
Let's find out! Type the
following into your command line: $ javac -version $ java -
version You should
have at least Javac 1.8 and Java 1.8 (often called “Java 8”)
installed. If that's not the
case, this is a good time to fix that by updating your Java. We
will be using some
features of Java 8 in this class.
Compile your java program.
$ javac TraceryRecursion.java
So far, it will compile without errors.
Look in the folder, and you will see that you have a new file
TraceryRecursion.class.
This is the compiled version of your file. You can now run this
file by typing:
$ java TraceryRecursion
You should get the output Running TraceryRecursion....
Try typing javac TraceryRecursion or java
TraceryRecursion.java. Both of these
should give your errors. Compiling requires the .java extension,
and running requires
not having it. But it’s easy and common to misremember that,
so look at what there
errors look like, so that when it happens later, you know what
caused it.
You can compile and run in separate steps. But sometimes you
want to compile and run
with one line, and you can combine them like this:
$ javac TraceryRecursion.java && java TraceryRecursion .
Store arguments
Many java programs need outside information provided by the
user. This lets users
change the behavior of the program (or tell it which data to use)
without having to
modify the source code.
The main method of TraceryRecursion will be the first method
called when running
the program. This method is static, meaning that the method is
associated directly
with a class and can thus be called without creating an object
that is an instance of the
class, and its return type is void, meaning that it won't return
anything. It also has
parameters, an array of Strings called args (you could call this
parameter anything, but
the tradition is to call it args or arguments).
Our program will take 0-4 arguments:
● the name of the file containing the grammar (e.g.:
"grammar.txt")
● the starting symbol to begin the grammar expansion (e.g.:
"#story#")
● the number of times we want to perform that expansion (e.g:
"5")
● a seed value for the random number generator (e.g: "123")
(Seeded random
values allow us to make the random generator predictable)
You can see that in main, each variable is given a default value.
For example, if no seed
value is given in the arguments, the seed value will be the
current time (this means you
will get different random results each time you run the program,
unless a specific seed
is specified in the arguments).
TODO #1
For each of these parameters, test whether enough arguments
have been specified to
set that parameter. For example, to set the grammarFile
parameter there would have
to be at least one argument given. You can test the length of the
args array to
determine how many arguments have been passed in. Override
each of these default
parameters with its argument override. For the numbers, you
will need to use
Integer.parseInt and Long.parseLong to turn the arguments from
Strings into
numbers. NOTE: Do not add or remove code outside of the
START and END
comments. Keeping all your code between those two comments
will help us
grade your work.
Load a Tracery file
Java has many helpful built-in data structures: Lists, Arrays,
and Hashtables are only a
few of them. In this assignment, we will be loading and storing
a Tracery grammar as a
Hashtable. The Hashtable has a list of keys, and each key has
some data associated
with it, much like a dictionary stores words with their
definition. Hashtables come with
some helpful methods included:
● table.get(String s) returns the data for that key, but it will
throw an error if
that key is not in the table.
● table.put(String s, DATA) creates an entry for that key (or
replaces it) and
stores the data there.
In this part of the assignment, we will implement loadGrammar,
which takes a String
representing a file path, then loads a file, parses it (breaking it
into sections), and stores
it in our grammar object.
In the loadGrammar method, we have already added the line
that creates the
Hashtable. You can see that the data type has a weird ending
<String, Rule[]>,
which tells Java that this Hashtable uses Strings to look up
arrays of Rules, so if we try
to use numbers as look up values, or store Strings instead of
arrays of Rules, Java
knows to throw an error.
We also included a basic way to load a file. Loading files might
cause an IO exception
(for example, if the file does not exist), so for complex reasons,
we need to have the
loading line
new String(Files.readAllBytes(Paths.get(path)))
wrapped in a try/catch block. We will talk more about throwing
and catching
exceptions later this quarter. For right now, this loads a whole
file as a string. By
appending .split('r?n') on the end, we take the resulting string
and splits it into
an array of lines.
TODO #2
For each line in the array of lines, store the data in the grammar
hashtable. You can use
either a familiar for (int i = 0...) loop, or use the newer for
(String line:
lines) loop, if you don't need to see the index value.
We used the split String method above to split apart the file into
lines. Use split
again, but splitting on the character ":". Everything before the
":" is the key. Store it in
a variable named key. Everything after it is the rule
expansion(s).
First split apart the rules into an array of Strings. For each line
in the file, this will give
you a String array of length 2, where the first element of the
array is an expandable
symbol (which will be a key in the grammar hashtable), and the
second element of the
array is the expansion(s) for this symbol. But there is possibly
more than one expansion
for a symbol. If you look at the grammar files, you can see
where there is more than one
expansion for a symbol when there's a comma-delimited list of
expansions after a
symbol. So we have to further split the expansions into an array
of Strings, one for each
expansion (by splitting on ",").
Once you have an array of Strings (of expansions) we have to
turn it into an array of
Rules. Initialize an array, Rule[], of the right size. Use another
loop (inside the loop
iterating through lines) to iterate through your array of strings
and, for each expansion,
create a Rule (it takes a single string as a parameter), and add it
to your array of Rules.
You now have the right kind of data (Rule[]) to store in the
hashtable.
Store your data in grammar. What was that method that stores
data in a grammar (hint:
we describe it above)?
In the main() method there's already a call to outputGrammar;
this prints your grammar
to the console, so you can verify that it loaded it correctly (that
the correct expansions
are associated with the correct symbols).
Implementing Recursion
Now that you have successfully loaded a file and stored it as a
Hashtable<String,
Rule[]> grammar, we can implement the method that generates
the generative text!
Open up Rule.java, and look at the constructor for this class:
Rule(String raw).
This constructor takes the string that you passed to it in TODO
#2 and splits it into
sections (using "#"). The even indexed entries of sections are
plain text (ie. the zeroth,
second, fourth, etc.), and the odd indexed entries of the variable
sections are symbols
for expanding (ie. the first, third, fifth, etc.). This might seem a
bit confusing at first. In an
expansion like "once #character# and #character# went to a
#place#" it's
clear that splitting on # will cause the zeroth, second and fourth
elements (the even
elements) to be plain text (i.e. "once", "and" and "went to a")
and the first, third and
fifth elements (the odd elements) to be symbols (i.e.
"#character#", "#character#",
"#place#"). But consider the expansion "#name# the #adjective#
#animal#".
Won't this even and odd approach get reversed, since the
expansion starts with a
symbol? It turns out it won't because, if there's a symbol at the
beginning, or two
symbols right next to each other, splitting on "#" produces two
strings, the empty string
(which is what is before the "#") and then the string with the
symbol (which is what is
after the "#", minus the closing "#" since we're splitting on "#").
So splitting this
expansion on # will produce the following array:
sections[0]: ""
sections[1]: "name"
sections[2]: "the"
sections[3]: "adjective"
sections[4]: ""
sections[5]: "animal"
So the even and odd relationship still works out, it's just that
two of our even entries are
the empty string (which is still plain text), which, when we
include it in the output of the
expansion, won't be visible, and so won't cause us any
problems. Phew! Now that we've
explained that we can get back to actually writing the code in
Rule.java to expand the
text.
The method expand takes a grammar (the type is
Hashtable<String, Rule[]>) as an
argument, and returns the expanded String. But right now, it
only returns a copy of its
original expansion (with any symbols not expanded). We want it
to instead recursively
expand the odd sections.
TODO #3
Create an array of Strings named results that is the same size as
the rule sections
( sections.length). This is where we will store the results of
expanding each section.
Create a for-loop that iterates down the sections array. Since we
need to know whether
each section is odd or even, you will need to use for (int i = 0
...), rather than
for (String section: sections) style loops. For each section, if it
is even ( i%2 ==
0), copy the text from the rule section into the results array.
If it is odd, then this is a symbol that we need to expand. Use
the grammar to find the
array of expansions for this symbol. We need to pick a
“random” index in the array, but
we will use the seeded random number generator (so we can
reproduce our results
using the same random seed). You can get a random int with
random.nextInt(int
bound). This will return a random integer between 0 (inclusive)
and the bound argument
you pass in (exclusive). Since you're randomly picking from an
array of possible
expansions, what's the largest random value you will want? Pick
out an expansion, and
save it as the variable Rule selectedExpansion.
We want to store that new value in our results array, but since is
is an expansion
string we need to process it first because it might contain
symbols that need to be
expanded as well. What method should you call on
selectedExpansion to do that?
Store the resulting text in the results array.
We now have results values for each section in this rule! Use
String.join("",
results) to join all of the results together into a single string
(with no spaces between
them), and return the results of that operation. This new return
statement should replace
the return statement that was in the starter code. That is, your
new return statement
should replace the line: return "[" + raw + "]";
Finishing up
Run your program. It should now output however many outputs
of the text you want (as
specified by the count parameter). Try it with and without a
seed value. Does it always
output something new? Try out a few other grammars, we
included
grammar-recipe.txt which makes bad recipes, and grammar-
emojistory.txt which
tells stories with emoji.
Now edit grammar-yourgrammar.txt. Create something
interesting (of about equal
complexity to grammar-story.txt). We won't judge you on what
it makes, consider this
a freeplay exercise. Some inspirational twitterbots include
@unicode_garden,
@DUNSONnDRAGGAN, @orcish_insults, @GameIdeaGarden ,
@indulgine,
@CombinationBot, @thinkpiecebot, @infinite_scream,
FartingEmoji.
Make sure your grammar generates without causing errors! We
didn't implement a
graceful way to recover from bad formatting or missing
symbols, so these grammars are
brittle, they break easily.
Turn in
Wow, you're done! Congrats on finishing your first 12B lab.
Checklist:
● Works for no command‑line arguments, a few, or all of them
● If a random seed is specified, the output stays consistent. If
not, it changes
● If you switch the grammar file, you get output from a
different grammar
● You have edited grammar-yourgrammar.txt and it runs.
To check that your code is right, compare it with the following
output. This output
assumes that you’re using Random.nextInt() to generate the
random numbers (as
described above). This is running TraceryRecursion with the
following arguments:
$ java TraceryRecursion grammar-story.txt "#origin#" 5 10
The output should be:
Running TraceryRecursion...
with grammar:'grammar-story.txt' startsymbol:'#origin#'
count:5 seed:10
Set seed 10
animal:cat,emu,okapi
emotion:happy,sad,elated,curious,sleepy
color:red,green,blue
name:emily,luis,otavio,anna,charlie
character:#name# the #adjective# #animal#
place:school,the beach,the zoo,Burning Man
adjective:#color#,#emotion#,
origin:once #character# and #character# went to #place#
GRAMMAR:
adjective: "#color#","#emotion#",
place: "school","the beach","the zoo","Burning Man",
emotion: "happy","sad","elated","curious","sleepy",
origin: "once #character# and #character# went to
#place#",
color: "red","green","blue",
name: "emily","luis","otavio","anna","charlie",
character: "#name# the #adjective# #animal#",
animal: "cat","emu","okapi",
once anna the green emu and anna the sleepy emu went to the
zoo
once emily the green emu and anna the green cat went to school
once charlie the blue okapi and otavio the blue emu went to
school
once emily the blue emu and otavio the blue cat went to the
beach
once emily the sad okapi and charlie the elated okapi went to
the zoo
To turn in your code:
● Create a directory with the following name: <student
ID>_lab1 where you
replace <student ID> with your actual student ID. For example,
if your student
ID is 1234567, then the directory name is 1234567_lab1.
● Put a copy of your edited TraceryRecursion.java, Rule.java
and
grammar-yourgrammar.txt files in the directory.
● Compress the folder using zip to create. Zip is a compression
utility available on
mac, linux and windows that can compress a directory into a
single file. This
should result in a file named <student ID>_lab1.zip (with
<student ID>
replaced with your real ID of course).
● Upload the zip file through the page for Lab 1 in canvas
( https://canvas.ucsc.edu/courses/12730/assignments/36933).
Additional resources
● How should I name things in Java?
https://www.javatpoint.com/java‑naming‑conventions
● Basic Java Syntax
https://www.tutorialspoint.com/java/java_basic_syntax.htm
● Need some in‑depth Java tutorials? There are free courses
online:
https://www.codecademy.com/learn/learn‑java ,
https://www.udemy.com/java‑tutorial/
● Command line basics:
https://hellowebbooks.com/learn‑command‑line/
● Get Linux/OSX style command line tools on Windows with
Cygwin
https://cygwin.com/install.html
https://canvas.ucsc.edu/courses/12730/assignments/36933
https://www.javatpoint.com/java%E2%80%91naming%E2%80%
91conventions
https://www.tutorialspoint.com/java/java_basic_syntax.htm
https://www.codecademy.com/learn/learn%E2%80%91java
https://www.udemy.com/java%E2%80%91tutorial/
https://hellowebbooks.com/learn%E2%80%91command%E2%80
%91line/
https://cygwin.com/install.html
Utilizing the readings from the text and your research, provide
an in-depth analysis of 3 social media platforms and how
businesses are utilizing them to reach new and existing
customers. Specific groups to be addressed are Generation X,
Generation Y, Millennials, Baby Boomers, and 60+ market
segments.
An example of a discussion idea is to research the trend toward
mobility in social media and write a paper on how the different
markets described in your Week 1 Individual Project use
technology.
Note: Research is to be academic or professional in scope. Use
of blogs, personal Web sites, corporate Web sites, wikis, or
other social-media-related sources are not acceptable.
A minimum of 4 pages is required. Title and abstract pages do
not count toward the page minimum. A minimum of 5
professional or academic references is required to support your
paper and to provide additional discussion points.
17
VIDEO AND PODCASTING MADE EASY
Creating audio and video content for marketing and PR
purposes requires the same attention to appropriate topics as
other techniques outlined in this book. It requires targeting
individual buyer personas with thoughtful information that
addresses some aspect of their lives or a problem they face. By
doing so, you brand your organization as smart and worthy of
doing business with. However, unlike text-based content such as
blogs or news releases, audio and video might require a modest
investment in additional hardware such as microphones and
video cameras, as well as software, and, depending on the level
of quality you want to achieve, may also necessitate time-
consuming editing of the files. Although the actual procedures
for podcasting and video are a bit more convoluted than, say,
starting a blog, they are still not all that difficult.
Video and Your Buyers
Organizations that deliver products or services that naturally
lend themselves to video have been among the first to actively
use the medium to market and deliver information about their
offerings. For example, many churches routinely shoot video of
weekly services and offer it online for anyone to watch, drawing
more people into the congregation. Many amateur and
professional sports teams, musicians, and theater groups also
use video as a marketing and PR tool.
Video follows both blogs and podcasting on the adoption curve
at organizations that don't have a service that naturally lends
itself to video. 303Companies are certainly experimenting,
typically by embedding video (hosted at YouTube or another
video site) into their existing blogs and online media rooms. I'm
also seeing video snippets of CEO speeches, customer
interviews, and quick product demonstrations.
Business-Casual Video
In the United States, there has been a 20-year trend toward so-
called business-casual clothing in the workplace. My first job,
on Wall Street in the 1980s, required me to wear a suit and tie
wi
18
HOW TO USE NEWS RELEASES TO REACH BUYERS
DIRECTLY
Guess what? Press releases have never been exclusively for the
press. My first job in the mid-1980s was on a Wall Street
trading desk. Every day, I would come to work and watch the
Dow Jones Telerate and Reuters screens as they displayed
specialized financial data, economic information, and stock
prices. The screens also displayed news feeds, and within these
news feeds were press releases. For decades, financial market
professionals have had access to company press releases
distributed through Business Wire, PR Newswire, and other
electronic press release distribution services. And they weren't
just for publicly traded corporations; any company's release
would appear in trading rooms within seconds.
I distinctly remember traders intently watching the newswires
for any signs of market-moving events. Often the headline of a
press release would cause frenzy: “Did you see? IBM is
acquiring a software company!” “It's on the wire; Boeing just
got a 20-plane order from Singapore Airlines!” For years,
markets often moved and stock prices rose and fell based on the
press release content issued directly by companies, noton the
news stories written minutes or hours later by reporters from
newswire outlets like Reuters and Dow Jones (and later
Bloomberg).
Press releases have also been available to professionals working
within corporations, government agencies, and law firms, all of
which have had access to press releases through services like
those from NewsEdge, Dow Jones, and LexisNexis. These
services have been delivering press releases to all kinds of
professionals for competitive intelligence, research, discovery,
and other purposes for decades.
316
And since about 1995, the wide availability of the web has
meant that press releases have been available for free to anyone
with an Internet connection and a web browser.
Millions of people read press releases directly, unfiltered by the
media. You need to be speaking directly.
YOUR NEWSROOM: A FRONT DOOR FOR MUCH MORE
THAN THE MEDIA
The online newsroom (sometimes called a press room, media
room, or press page) is the part of your organization's website
that you create specifically for the media. In some
organizations, this section is simply a list of news releases with
contact information for the organization's PR person. But many
companies and nonprofits have elaborate newsrooms with a
great deal of information available in many different formats:
audio, video, photos, news releases, background information,
financial data, and much more. A close cousin to the newsroom
is the online investor relations (IR) room that many public
companies maintain; however, I don't cover IR sites in this
book.
Before I give you ideas on how to create a valuable newsroom
of your own, I want you to consider something that is vitally
important: All kinds of people visit your newsroom, not just
journalists. Stop and really let that soak in for a moment. Your
buyers are snooping around your organization by visiting the
media pages on your website. Your current customers, partners,
investors, suppliers, and employees all visit those pages. Why is
that? Based on casual research I've done (I often speak about
visitor statistics with employees who are responsible for their
organizations' newsrooms), I'm convinced that when people
want to know what's currentabout an organization, they go to a
newsroom.
Your newsroom is for your buyers, not just the media.
329Visitors expect that the main pages of a website are
basically static (i.e., they are not updated often), but they also
expect that the news releases and media-targeted pages on a site
will reveal the very latest about a company. For many
companies, the news release section is one of the most
frequently visited parts of the website. Check out your own
website statistics; you may be amazed at how many visitors are
already reading your news releases and other media pages
online.
So I want you to do something that many traditional PR people
think is nuts. I want you to design your newsroom for
your buyers. By building a media room that targets buyers, you
will not only enhance those pages as a powerful marketing tool
but also make a better media site for journalists. I've reviewed
hundreds of newsrooms, and the best ones are built with buyers
in mind. This approach may sound a bit radical, but believe me,
it works.
When news releases are posted on your site, search engine
crawlers will find the content, index it, and rank it based on
words, phrases, and other factors. Because news release pages
update more often than any other part of a typical organization's
website, search engine algorithms (tuned to pay attention to
pages that update frequently) tend to rank news release pages
among the highest on your site, driving traffic there first.
“There's no question that a well-organized media room often has
higher search results and drives more traffic because of the way
the search engines work,” says Dee Rambeau, vice president of
customer engagement at PR Newswire. “A news release
dynamically builds out a new set of content in your newsroom,
with each news release generating its own indexable page,
which the search engines all capture. Google and the other
search engines love fresh content that relates back to similar
content on the other pages of the site. Aggressive companies
take advantage of this by sending news releases frequently to
get high rankings from the search engines. Frequency has a
great deal to do with search engine rankings—if you do 10 news
releases, that's great; 20 is better, and 100 is better still.”
The Kellogg Company—the world's leading producer of cereal
and second-largest producer of cookies, crackers, and savory
snacks—uses its newsroom1for search engine optimization
(SEO) purposes and as a tool to reach various audiences,
including reporters and editors who cover the company.
“What we found through our research is that, more and more,
our newsroom is extending beyond just media to other
stakeholders,” says Stephanie Slingerland, senior manager of
corporate communications at the Kellogg Company. “Anyone
coming to the site, be it an investor, an NGO or other partner
agency, or even a consumer—the newsroom is inviting for them
to get the information which may be relevant.”
Slingerland has strong partnerships with people who work in
other departments at the company and who also provide
information to the public. “Our investor relations team are
having conversations and engagements with analysts and
investors. So, from our partnership with that team, we know
what those stakeholders might be looking for. Or, for example,
our government relations team are regularly engaging with
government and nongovernmental officials. Again, we have a
strong partnership with them. We know what they're looking for
and can make sure that they have what they might be looking
for on our site. The same with our corporate social
responsibility team, who engage with agencies and others as
part of our philanthropic activities.”
Based on what she learns about the needs of the news media and
other stakeholders, Slingerland creates the right content,
including news releases, fact sheets, news alerts, and more.
“Since we are the folks that regularly engage with the media,
we know what we're getting asked for over and over, like the
fact sheet section,” she says. “And we also know that many
people want to know the latest news about the company, but
they don't necessarily come to our newsroom every day. So
that's why we created our news alerts section, so they opt in to
be alerted whenever
One important consideration that many marketing and PR
people overlook when considering the benefits of a newsroom is
that you control the content, not your IT department,
webmaster, or anyone else. Youshould design your newsroom as
a tool to reach buyers and journalists, and you don't need to
take into consideration the rules for posting content that the rest
of the organization's site may require. If you build this part of
your site using a specialized newsroom content-management
application, such as the MediaRoom2product from PR
Newswire, you will control a corner of your organization's
website that you can update whenever you like using simple
tools, and you won't need to request help from anyone in other
departments or locations. So start with your needs and the needs
of your buyers and journalists, not the needs of those who own
the other parts of your organization's website.
Start with a Needs Analysis
When designing a new newsroom (or planning an extensive
redesign), start with a needs analysis. Before you just jump
right into site aesthetics and the organization of news releases,
take time to analyze how the site fits into your 332larger
marketing, PR, and media relations strategy. Consider the buyer
persona profiles you built as part of your marketing and PR
plan. Talk with friendly journalists so you can understand what
they need. Who are the potential users of the newsroom, and
what content will be valuable to them? When you have collected
some information, build buyers' and journalists' needs into your
newsroom.
As you work toward starting your design, try to think a bit more
like a publisher and less like a marketing and PR person. A
publisher carefully identifies and defines target audiences and
then develops the content required to meet the needs of each
distinct demographic. Graphical elements, colors, fonts, and
other visual manifestations of the site are also important but
should take a backseat during the content needs analysis
process.

More Related Content

Similar to Lab 1 Recursion  Introduction   Tracery (tracery.io.docx

Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
Martin Odersky
 
C interview-questions-techpreparation
C interview-questions-techpreparationC interview-questions-techpreparation
C interview-questions-techpreparationKushaal Singla
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
karymadelaneyrenne19
 
JavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java codeJavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java code
Federico Tomassetti
 
Java mcq
Java mcqJava mcq
Java mcq
avinash9821
 
Java 8
Java 8Java 8
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction
AKR Education
 
220 runtime environments
220 runtime environments220 runtime environments
220 runtime environments
J'tong Atong
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsOCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIs
İbrahim Kürce
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
Hamid Ghorbani
 
Introduction to es6
Introduction to es6Introduction to es6
Introduction to es6
NexThoughts Technologies
 
Matlab Manual
Matlab ManualMatlab Manual
Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameScala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameAntony Stubbs
 
Generics collections
Generics collectionsGenerics collections
Generics collections
Yaswanth Babu Gummadivelli
 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
theodorelove43763
 
Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)
Roy Zimmer
 
Apache avro data serialization framework
Apache avro   data serialization frameworkApache avro   data serialization framework
Apache avro data serialization framework
veeracynixit
 

Similar to Lab 1 Recursion  Introduction   Tracery (tracery.io.docx (20)

Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
C interview-questions-techpreparation
C interview-questions-techpreparationC interview-questions-techpreparation
C interview-questions-techpreparation
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
 
JavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java codeJavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java code
 
Md08 collection api
Md08 collection apiMd08 collection api
Md08 collection api
 
Java mcq
Java mcqJava mcq
Java mcq
 
Java 8
Java 8Java 8
Java 8
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction
 
220 runtime environments
220 runtime environments220 runtime environments
220 runtime environments
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsOCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIs
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Java programming-examples
Java programming-examplesJava programming-examples
Java programming-examples
 
Introduction to es6
Introduction to es6Introduction to es6
Introduction to es6
 
Matlab Manual
Matlab ManualMatlab Manual
Matlab Manual
 
Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameScala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love Game
 
Generics collections
Generics collectionsGenerics collections
Generics collections
 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
 
Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)
 
Apache avro data serialization framework
Apache avro   data serialization frameworkApache avro   data serialization framework
Apache avro data serialization framework
 
First fare 2010 java-introduction
First fare 2010 java-introductionFirst fare 2010 java-introduction
First fare 2010 java-introduction
 

More from smile790243

PART B Please response to these two original posts below. Wh.docx
PART B Please response to these two original posts below. Wh.docxPART B Please response to these two original posts below. Wh.docx
PART B Please response to these two original posts below. Wh.docx
smile790243
 
Part C Developing Your Design SolutionThe Production Cycle.docx
Part C Developing Your Design SolutionThe Production Cycle.docxPart C Developing Your Design SolutionThe Production Cycle.docx
Part C Developing Your Design SolutionThe Production Cycle.docx
smile790243
 
PART A You will create a media piece based around the theme of a.docx
PART A You will create a media piece based around the theme of a.docxPART A You will create a media piece based around the theme of a.docx
PART A You will create a media piece based around the theme of a.docx
smile790243
 
Part 4. Implications to Nursing Practice & Implication to Patien.docx
Part 4. Implications to Nursing Practice & Implication to Patien.docxPart 4. Implications to Nursing Practice & Implication to Patien.docx
Part 4. Implications to Nursing Practice & Implication to Patien.docx
smile790243
 
PART AHepatitis C is a chronic liver infection that can be e.docx
PART AHepatitis C is a chronic liver infection that can be e.docxPART AHepatitis C is a chronic liver infection that can be e.docx
PART AHepatitis C is a chronic liver infection that can be e.docx
smile790243
 
Part A post your answer to the following question1. How m.docx
Part A post your answer to the following question1. How m.docxPart A post your answer to the following question1. How m.docx
Part A post your answer to the following question1. How m.docx
smile790243
 
PART BPlease response to these two original posts below..docx
PART BPlease response to these two original posts below..docxPART BPlease response to these two original posts below..docx
PART BPlease response to these two original posts below..docx
smile790243
 
Part A (50 Points)Various men and women throughout history .docx
Part A (50 Points)Various men and women throughout history .docxPart A (50 Points)Various men and women throughout history .docx
Part A (50 Points)Various men and women throughout history .docx
smile790243
 
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docx
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docxPart A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docx
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docx
smile790243
 
Part A Develop an original age-appropriate activity for your .docx
Part A Develop an original age-appropriate activity for your .docxPart A Develop an original age-appropriate activity for your .docx
Part A Develop an original age-appropriate activity for your .docx
smile790243
 
Part 3 Social Situations2. Identify multicultural challenges th.docx
Part 3 Social Situations2. Identify multicultural challenges th.docxPart 3 Social Situations2. Identify multicultural challenges th.docx
Part 3 Social Situations2. Identify multicultural challenges th.docx
smile790243
 
Part A (1000 words) Annotated Bibliography - Create an annota.docx
Part A (1000 words) Annotated Bibliography - Create an annota.docxPart A (1000 words) Annotated Bibliography - Create an annota.docx
Part A (1000 words) Annotated Bibliography - Create an annota.docx
smile790243
 
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docx
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docxPart 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docx
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docx
smile790243
 
Part 3 Social Situations • Proposal paper which identifies multicul.docx
Part 3 Social Situations • Proposal paper which identifies multicul.docxPart 3 Social Situations • Proposal paper which identifies multicul.docx
Part 3 Social Situations • Proposal paper which identifies multicul.docx
smile790243
 
Part 3 Social Situations 2. Identify multicultural challenges that .docx
Part 3 Social Situations 2. Identify multicultural challenges that .docxPart 3 Social Situations 2. Identify multicultural challenges that .docx
Part 3 Social Situations 2. Identify multicultural challenges that .docx
smile790243
 
Part 2The client is a 32-year-old Hispanic American male who c.docx
Part 2The client is a 32-year-old Hispanic American male who c.docxPart 2The client is a 32-year-old Hispanic American male who c.docx
Part 2The client is a 32-year-old Hispanic American male who c.docx
smile790243
 
Part 2For this section of the template, focus on gathering deta.docx
Part 2For this section of the template, focus on gathering deta.docxPart 2For this section of the template, focus on gathering deta.docx
Part 2For this section of the template, focus on gathering deta.docx
smile790243
 
Part 2 Observation Summary and Analysis • Summary paper of observat.docx
Part 2 Observation Summary and Analysis • Summary paper of observat.docxPart 2 Observation Summary and Analysis • Summary paper of observat.docx
Part 2 Observation Summary and Analysis • Summary paper of observat.docx
smile790243
 
Part 2 Observation Summary and Analysis 1. Review and implement any.docx
Part 2 Observation Summary and Analysis 1. Review and implement any.docxPart 2 Observation Summary and Analysis 1. Review and implement any.docx
Part 2 Observation Summary and Analysis 1. Review and implement any.docx
smile790243
 
Part 2Data collectionfrom your change study initiative,.docx
Part 2Data collectionfrom your change study initiative,.docxPart 2Data collectionfrom your change study initiative,.docx
Part 2Data collectionfrom your change study initiative,.docx
smile790243
 

More from smile790243 (20)

PART B Please response to these two original posts below. Wh.docx
PART B Please response to these two original posts below. Wh.docxPART B Please response to these two original posts below. Wh.docx
PART B Please response to these two original posts below. Wh.docx
 
Part C Developing Your Design SolutionThe Production Cycle.docx
Part C Developing Your Design SolutionThe Production Cycle.docxPart C Developing Your Design SolutionThe Production Cycle.docx
Part C Developing Your Design SolutionThe Production Cycle.docx
 
PART A You will create a media piece based around the theme of a.docx
PART A You will create a media piece based around the theme of a.docxPART A You will create a media piece based around the theme of a.docx
PART A You will create a media piece based around the theme of a.docx
 
Part 4. Implications to Nursing Practice & Implication to Patien.docx
Part 4. Implications to Nursing Practice & Implication to Patien.docxPart 4. Implications to Nursing Practice & Implication to Patien.docx
Part 4. Implications to Nursing Practice & Implication to Patien.docx
 
PART AHepatitis C is a chronic liver infection that can be e.docx
PART AHepatitis C is a chronic liver infection that can be e.docxPART AHepatitis C is a chronic liver infection that can be e.docx
PART AHepatitis C is a chronic liver infection that can be e.docx
 
Part A post your answer to the following question1. How m.docx
Part A post your answer to the following question1. How m.docxPart A post your answer to the following question1. How m.docx
Part A post your answer to the following question1. How m.docx
 
PART BPlease response to these two original posts below..docx
PART BPlease response to these two original posts below..docxPART BPlease response to these two original posts below..docx
PART BPlease response to these two original posts below..docx
 
Part A (50 Points)Various men and women throughout history .docx
Part A (50 Points)Various men and women throughout history .docxPart A (50 Points)Various men and women throughout history .docx
Part A (50 Points)Various men and women throughout history .docx
 
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docx
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docxPart A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docx
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docx
 
Part A Develop an original age-appropriate activity for your .docx
Part A Develop an original age-appropriate activity for your .docxPart A Develop an original age-appropriate activity for your .docx
Part A Develop an original age-appropriate activity for your .docx
 
Part 3 Social Situations2. Identify multicultural challenges th.docx
Part 3 Social Situations2. Identify multicultural challenges th.docxPart 3 Social Situations2. Identify multicultural challenges th.docx
Part 3 Social Situations2. Identify multicultural challenges th.docx
 
Part A (1000 words) Annotated Bibliography - Create an annota.docx
Part A (1000 words) Annotated Bibliography - Create an annota.docxPart A (1000 words) Annotated Bibliography - Create an annota.docx
Part A (1000 words) Annotated Bibliography - Create an annota.docx
 
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docx
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docxPart 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docx
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docx
 
Part 3 Social Situations • Proposal paper which identifies multicul.docx
Part 3 Social Situations • Proposal paper which identifies multicul.docxPart 3 Social Situations • Proposal paper which identifies multicul.docx
Part 3 Social Situations • Proposal paper which identifies multicul.docx
 
Part 3 Social Situations 2. Identify multicultural challenges that .docx
Part 3 Social Situations 2. Identify multicultural challenges that .docxPart 3 Social Situations 2. Identify multicultural challenges that .docx
Part 3 Social Situations 2. Identify multicultural challenges that .docx
 
Part 2The client is a 32-year-old Hispanic American male who c.docx
Part 2The client is a 32-year-old Hispanic American male who c.docxPart 2The client is a 32-year-old Hispanic American male who c.docx
Part 2The client is a 32-year-old Hispanic American male who c.docx
 
Part 2For this section of the template, focus on gathering deta.docx
Part 2For this section of the template, focus on gathering deta.docxPart 2For this section of the template, focus on gathering deta.docx
Part 2For this section of the template, focus on gathering deta.docx
 
Part 2 Observation Summary and Analysis • Summary paper of observat.docx
Part 2 Observation Summary and Analysis • Summary paper of observat.docxPart 2 Observation Summary and Analysis • Summary paper of observat.docx
Part 2 Observation Summary and Analysis • Summary paper of observat.docx
 
Part 2 Observation Summary and Analysis 1. Review and implement any.docx
Part 2 Observation Summary and Analysis 1. Review and implement any.docxPart 2 Observation Summary and Analysis 1. Review and implement any.docx
Part 2 Observation Summary and Analysis 1. Review and implement any.docx
 
Part 2Data collectionfrom your change study initiative,.docx
Part 2Data collectionfrom your change study initiative,.docxPart 2Data collectionfrom your change study initiative,.docx
Part 2Data collectionfrom your change study initiative,.docx
 

Recently uploaded

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 

Recently uploaded (20)

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 

Lab 1 Recursion  Introduction   Tracery (tracery.io.docx

  • 1. Lab 1: Recursion Introduction Tracery (tracery.io) is a simple text-expansion language made by one of your TAs as a homework assignment for one of Prof. Mateas's previous courses. It now has tens of thousands of users, and runs about 7000 chatbots on Twitter (you never know where a homework will take you!). Tracery uses context-free grammars ( https://en.wikipedia.org/wiki/Context-free_grammar) to store information about how to expand rules. A Tracery grammar is a set of keys, each of which has some set of expansions that can replace it. In our version, the line "beverage:tea|coffee|cola|milk" means that the symbol "beverage" can be replaced with any of those four options. You replace a symbol whenever you see it in hashtags. This rule "#name# drank a glass of #beverage#" will have the "name" and "beverage" symbols replaced with expansions associated with those symbols. In the case of the "beverage" rule above, which has four possible expansions, one will be picked at random. If the replacement rule also has hashtags in it, we replace those, and if those replacements have hashtags.... we keep replacing things
  • 2. until all the hashtags are gone, recursively. In this assignment, you will be implementing a simplified version of Tracery in Java, and then using it to generate generative text. You will also be writing your own grammar to generate new texts (hipster cocktails, emoji stories, or nonsense poems). Outline ● Compile and run a Java program ● Save all the arguments ● Load the Tracery files ● Output all the rules ● Expand rules and print them to the screen Compile and run a Java program This program has several files (Rule.java, and TraceryRecursion.java). We can't run these files as code, as we would with other “interpreted” languages (like Javascript https://en.wikipedia.org/wiki/Context-free_grammar or Python). For Java, we need the computer to put them all together and translate it to machine code, in a process called “compiling”. You will compile and run your Java program from the command line. When you see $, this means that it is a command that you will enter in the command line. Windows and
  • 3. Unix (such as Linux or the Mac terminal) command lines are a little different, be sure you know the basics of navigating the one you are using. Do you have Java installed on your machine? What version? Let's find out! Type the following into your command line: $ javac -version $ java - version You should have at least Javac 1.8 and Java 1.8 (often called “Java 8”) installed. If that's not the case, this is a good time to fix that by updating your Java. We will be using some features of Java 8 in this class. Compile your java program. $ javac TraceryRecursion.java So far, it will compile without errors. Look in the folder, and you will see that you have a new file TraceryRecursion.class. This is the compiled version of your file. You can now run this file by typing: $ java TraceryRecursion You should get the output Running TraceryRecursion.... Try typing javac TraceryRecursion or java TraceryRecursion.java. Both of these should give your errors. Compiling requires the .java extension, and running requires not having it. But it’s easy and common to misremember that, so look at what there errors look like, so that when it happens later, you know what
  • 4. caused it. You can compile and run in separate steps. But sometimes you want to compile and run with one line, and you can combine them like this: $ javac TraceryRecursion.java && java TraceryRecursion . Store arguments Many java programs need outside information provided by the user. This lets users change the behavior of the program (or tell it which data to use) without having to modify the source code. The main method of TraceryRecursion will be the first method called when running the program. This method is static, meaning that the method is associated directly with a class and can thus be called without creating an object that is an instance of the class, and its return type is void, meaning that it won't return anything. It also has parameters, an array of Strings called args (you could call this parameter anything, but the tradition is to call it args or arguments). Our program will take 0-4 arguments: ● the name of the file containing the grammar (e.g.: "grammar.txt") ● the starting symbol to begin the grammar expansion (e.g.: "#story#") ● the number of times we want to perform that expansion (e.g:
  • 5. "5") ● a seed value for the random number generator (e.g: "123") (Seeded random values allow us to make the random generator predictable) You can see that in main, each variable is given a default value. For example, if no seed value is given in the arguments, the seed value will be the current time (this means you will get different random results each time you run the program, unless a specific seed is specified in the arguments). TODO #1 For each of these parameters, test whether enough arguments have been specified to set that parameter. For example, to set the grammarFile parameter there would have to be at least one argument given. You can test the length of the args array to determine how many arguments have been passed in. Override each of these default parameters with its argument override. For the numbers, you will need to use Integer.parseInt and Long.parseLong to turn the arguments from Strings into numbers. NOTE: Do not add or remove code outside of the START and END comments. Keeping all your code between those two comments will help us grade your work. Load a Tracery file
  • 6. Java has many helpful built-in data structures: Lists, Arrays, and Hashtables are only a few of them. In this assignment, we will be loading and storing a Tracery grammar as a Hashtable. The Hashtable has a list of keys, and each key has some data associated with it, much like a dictionary stores words with their definition. Hashtables come with some helpful methods included: ● table.get(String s) returns the data for that key, but it will throw an error if that key is not in the table. ● table.put(String s, DATA) creates an entry for that key (or replaces it) and stores the data there. In this part of the assignment, we will implement loadGrammar, which takes a String representing a file path, then loads a file, parses it (breaking it into sections), and stores it in our grammar object. In the loadGrammar method, we have already added the line that creates the Hashtable. You can see that the data type has a weird ending <String, Rule[]>, which tells Java that this Hashtable uses Strings to look up arrays of Rules, so if we try to use numbers as look up values, or store Strings instead of arrays of Rules, Java knows to throw an error.
  • 7. We also included a basic way to load a file. Loading files might cause an IO exception (for example, if the file does not exist), so for complex reasons, we need to have the loading line new String(Files.readAllBytes(Paths.get(path))) wrapped in a try/catch block. We will talk more about throwing and catching exceptions later this quarter. For right now, this loads a whole file as a string. By appending .split('r?n') on the end, we take the resulting string and splits it into an array of lines. TODO #2 For each line in the array of lines, store the data in the grammar hashtable. You can use either a familiar for (int i = 0...) loop, or use the newer for (String line: lines) loop, if you don't need to see the index value. We used the split String method above to split apart the file into lines. Use split again, but splitting on the character ":". Everything before the ":" is the key. Store it in a variable named key. Everything after it is the rule expansion(s). First split apart the rules into an array of Strings. For each line in the file, this will give you a String array of length 2, where the first element of the array is an expandable symbol (which will be a key in the grammar hashtable), and the
  • 8. second element of the array is the expansion(s) for this symbol. But there is possibly more than one expansion for a symbol. If you look at the grammar files, you can see where there is more than one expansion for a symbol when there's a comma-delimited list of expansions after a symbol. So we have to further split the expansions into an array of Strings, one for each expansion (by splitting on ","). Once you have an array of Strings (of expansions) we have to turn it into an array of Rules. Initialize an array, Rule[], of the right size. Use another loop (inside the loop iterating through lines) to iterate through your array of strings and, for each expansion, create a Rule (it takes a single string as a parameter), and add it to your array of Rules. You now have the right kind of data (Rule[]) to store in the hashtable. Store your data in grammar. What was that method that stores data in a grammar (hint: we describe it above)? In the main() method there's already a call to outputGrammar; this prints your grammar to the console, so you can verify that it loaded it correctly (that the correct expansions are associated with the correct symbols). Implementing Recursion
  • 9. Now that you have successfully loaded a file and stored it as a Hashtable<String, Rule[]> grammar, we can implement the method that generates the generative text! Open up Rule.java, and look at the constructor for this class: Rule(String raw). This constructor takes the string that you passed to it in TODO #2 and splits it into sections (using "#"). The even indexed entries of sections are plain text (ie. the zeroth, second, fourth, etc.), and the odd indexed entries of the variable sections are symbols for expanding (ie. the first, third, fifth, etc.). This might seem a bit confusing at first. In an expansion like "once #character# and #character# went to a #place#" it's clear that splitting on # will cause the zeroth, second and fourth elements (the even elements) to be plain text (i.e. "once", "and" and "went to a") and the first, third and fifth elements (the odd elements) to be symbols (i.e. "#character#", "#character#", "#place#"). But consider the expansion "#name# the #adjective# #animal#". Won't this even and odd approach get reversed, since the expansion starts with a symbol? It turns out it won't because, if there's a symbol at the beginning, or two symbols right next to each other, splitting on "#" produces two strings, the empty string (which is what is before the "#") and then the string with the symbol (which is what is after the "#", minus the closing "#" since we're splitting on "#"). So splitting this expansion on # will produce the following array:
  • 10. sections[0]: "" sections[1]: "name" sections[2]: "the" sections[3]: "adjective" sections[4]: "" sections[5]: "animal" So the even and odd relationship still works out, it's just that two of our even entries are the empty string (which is still plain text), which, when we include it in the output of the expansion, won't be visible, and so won't cause us any problems. Phew! Now that we've explained that we can get back to actually writing the code in Rule.java to expand the text. The method expand takes a grammar (the type is Hashtable<String, Rule[]>) as an argument, and returns the expanded String. But right now, it only returns a copy of its original expansion (with any symbols not expanded). We want it to instead recursively expand the odd sections. TODO #3 Create an array of Strings named results that is the same size as the rule sections ( sections.length). This is where we will store the results of expanding each section.
  • 11. Create a for-loop that iterates down the sections array. Since we need to know whether each section is odd or even, you will need to use for (int i = 0 ...), rather than for (String section: sections) style loops. For each section, if it is even ( i%2 == 0), copy the text from the rule section into the results array. If it is odd, then this is a symbol that we need to expand. Use the grammar to find the array of expansions for this symbol. We need to pick a “random” index in the array, but we will use the seeded random number generator (so we can reproduce our results using the same random seed). You can get a random int with random.nextInt(int bound). This will return a random integer between 0 (inclusive) and the bound argument you pass in (exclusive). Since you're randomly picking from an array of possible expansions, what's the largest random value you will want? Pick out an expansion, and save it as the variable Rule selectedExpansion. We want to store that new value in our results array, but since is is an expansion string we need to process it first because it might contain symbols that need to be expanded as well. What method should you call on selectedExpansion to do that? Store the resulting text in the results array. We now have results values for each section in this rule! Use String.join("", results) to join all of the results together into a single string (with no spaces between
  • 12. them), and return the results of that operation. This new return statement should replace the return statement that was in the starter code. That is, your new return statement should replace the line: return "[" + raw + "]"; Finishing up Run your program. It should now output however many outputs of the text you want (as specified by the count parameter). Try it with and without a seed value. Does it always output something new? Try out a few other grammars, we included grammar-recipe.txt which makes bad recipes, and grammar- emojistory.txt which tells stories with emoji. Now edit grammar-yourgrammar.txt. Create something interesting (of about equal complexity to grammar-story.txt). We won't judge you on what it makes, consider this a freeplay exercise. Some inspirational twitterbots include @unicode_garden, @DUNSONnDRAGGAN, @orcish_insults, @GameIdeaGarden , @indulgine, @CombinationBot, @thinkpiecebot, @infinite_scream, FartingEmoji. Make sure your grammar generates without causing errors! We didn't implement a graceful way to recover from bad formatting or missing symbols, so these grammars are
  • 13. brittle, they break easily. Turn in Wow, you're done! Congrats on finishing your first 12B lab. Checklist: ● Works for no command‑line arguments, a few, or all of them ● If a random seed is specified, the output stays consistent. If not, it changes ● If you switch the grammar file, you get output from a different grammar ● You have edited grammar-yourgrammar.txt and it runs. To check that your code is right, compare it with the following output. This output assumes that you’re using Random.nextInt() to generate the random numbers (as described above). This is running TraceryRecursion with the following arguments: $ java TraceryRecursion grammar-story.txt "#origin#" 5 10 The output should be: Running TraceryRecursion... with grammar:'grammar-story.txt' startsymbol:'#origin#' count:5 seed:10 Set seed 10 animal:cat,emu,okapi emotion:happy,sad,elated,curious,sleepy
  • 14. color:red,green,blue name:emily,luis,otavio,anna,charlie character:#name# the #adjective# #animal# place:school,the beach,the zoo,Burning Man adjective:#color#,#emotion#, origin:once #character# and #character# went to #place# GRAMMAR: adjective: "#color#","#emotion#", place: "school","the beach","the zoo","Burning Man", emotion: "happy","sad","elated","curious","sleepy", origin: "once #character# and #character# went to #place#", color: "red","green","blue", name: "emily","luis","otavio","anna","charlie", character: "#name# the #adjective# #animal#", animal: "cat","emu","okapi", once anna the green emu and anna the sleepy emu went to the zoo once emily the green emu and anna the green cat went to school once charlie the blue okapi and otavio the blue emu went to school once emily the blue emu and otavio the blue cat went to the beach
  • 15. once emily the sad okapi and charlie the elated okapi went to the zoo To turn in your code: ● Create a directory with the following name: <student ID>_lab1 where you replace <student ID> with your actual student ID. For example, if your student ID is 1234567, then the directory name is 1234567_lab1. ● Put a copy of your edited TraceryRecursion.java, Rule.java and grammar-yourgrammar.txt files in the directory. ● Compress the folder using zip to create. Zip is a compression utility available on mac, linux and windows that can compress a directory into a single file. This should result in a file named <student ID>_lab1.zip (with <student ID> replaced with your real ID of course). ● Upload the zip file through the page for Lab 1 in canvas ( https://canvas.ucsc.edu/courses/12730/assignments/36933). Additional resources ● How should I name things in Java? https://www.javatpoint.com/java‑naming‑conventions ● Basic Java Syntax
  • 16. https://www.tutorialspoint.com/java/java_basic_syntax.htm ● Need some in‑depth Java tutorials? There are free courses online: https://www.codecademy.com/learn/learn‑java , https://www.udemy.com/java‑tutorial/ ● Command line basics: https://hellowebbooks.com/learn‑command‑line/ ● Get Linux/OSX style command line tools on Windows with Cygwin https://cygwin.com/install.html https://canvas.ucsc.edu/courses/12730/assignments/36933 https://www.javatpoint.com/java%E2%80%91naming%E2%80% 91conventions https://www.tutorialspoint.com/java/java_basic_syntax.htm https://www.codecademy.com/learn/learn%E2%80%91java https://www.udemy.com/java%E2%80%91tutorial/ https://hellowebbooks.com/learn%E2%80%91command%E2%80 %91line/ https://cygwin.com/install.html Utilizing the readings from the text and your research, provide an in-depth analysis of 3 social media platforms and how businesses are utilizing them to reach new and existing customers. Specific groups to be addressed are Generation X, Generation Y, Millennials, Baby Boomers, and 60+ market segments. An example of a discussion idea is to research the trend toward mobility in social media and write a paper on how the different markets described in your Week 1 Individual Project use technology. Note: Research is to be academic or professional in scope. Use of blogs, personal Web sites, corporate Web sites, wikis, or
  • 17. other social-media-related sources are not acceptable. A minimum of 4 pages is required. Title and abstract pages do not count toward the page minimum. A minimum of 5 professional or academic references is required to support your paper and to provide additional discussion points. 17 VIDEO AND PODCASTING MADE EASY Creating audio and video content for marketing and PR purposes requires the same attention to appropriate topics as other techniques outlined in this book. It requires targeting individual buyer personas with thoughtful information that addresses some aspect of their lives or a problem they face. By doing so, you brand your organization as smart and worthy of doing business with. However, unlike text-based content such as blogs or news releases, audio and video might require a modest investment in additional hardware such as microphones and video cameras, as well as software, and, depending on the level of quality you want to achieve, may also necessitate time- consuming editing of the files. Although the actual procedures for podcasting and video are a bit more convoluted than, say, starting a blog, they are still not all that difficult. Video and Your Buyers Organizations that deliver products or services that naturally lend themselves to video have been among the first to actively use the medium to market and deliver information about their offerings. For example, many churches routinely shoot video of weekly services and offer it online for anyone to watch, drawing more people into the congregation. Many amateur and professional sports teams, musicians, and theater groups also use video as a marketing and PR tool. Video follows both blogs and podcasting on the adoption curve at organizations that don't have a service that naturally lends itself to video. 303Companies are certainly experimenting, typically by embedding video (hosted at YouTube or another video site) into their existing blogs and online media rooms. I'm also seeing video snippets of CEO speeches, customer
  • 18. interviews, and quick product demonstrations. Business-Casual Video In the United States, there has been a 20-year trend toward so- called business-casual clothing in the workplace. My first job, on Wall Street in the 1980s, required me to wear a suit and tie wi 18 HOW TO USE NEWS RELEASES TO REACH BUYERS DIRECTLY Guess what? Press releases have never been exclusively for the press. My first job in the mid-1980s was on a Wall Street trading desk. Every day, I would come to work and watch the Dow Jones Telerate and Reuters screens as they displayed specialized financial data, economic information, and stock prices. The screens also displayed news feeds, and within these news feeds were press releases. For decades, financial market professionals have had access to company press releases distributed through Business Wire, PR Newswire, and other electronic press release distribution services. And they weren't just for publicly traded corporations; any company's release would appear in trading rooms within seconds. I distinctly remember traders intently watching the newswires for any signs of market-moving events. Often the headline of a press release would cause frenzy: “Did you see? IBM is acquiring a software company!” “It's on the wire; Boeing just got a 20-plane order from Singapore Airlines!” For years, markets often moved and stock prices rose and fell based on the press release content issued directly by companies, noton the news stories written minutes or hours later by reporters from newswire outlets like Reuters and Dow Jones (and later Bloomberg). Press releases have also been available to professionals working within corporations, government agencies, and law firms, all of which have had access to press releases through services like those from NewsEdge, Dow Jones, and LexisNexis. These
  • 19. services have been delivering press releases to all kinds of professionals for competitive intelligence, research, discovery, and other purposes for decades. 316 And since about 1995, the wide availability of the web has meant that press releases have been available for free to anyone with an Internet connection and a web browser. Millions of people read press releases directly, unfiltered by the media. You need to be speaking directly. YOUR NEWSROOM: A FRONT DOOR FOR MUCH MORE THAN THE MEDIA The online newsroom (sometimes called a press room, media room, or press page) is the part of your organization's website that you create specifically for the media. In some organizations, this section is simply a list of news releases with contact information for the organization's PR person. But many companies and nonprofits have elaborate newsrooms with a great deal of information available in many different formats: audio, video, photos, news releases, background information, financial data, and much more. A close cousin to the newsroom is the online investor relations (IR) room that many public companies maintain; however, I don't cover IR sites in this book. Before I give you ideas on how to create a valuable newsroom of your own, I want you to consider something that is vitally important: All kinds of people visit your newsroom, not just journalists. Stop and really let that soak in for a moment. Your buyers are snooping around your organization by visiting the media pages on your website. Your current customers, partners, investors, suppliers, and employees all visit those pages. Why is that? Based on casual research I've done (I often speak about visitor statistics with employees who are responsible for their organizations' newsrooms), I'm convinced that when people want to know what's currentabout an organization, they go to a newsroom. Your newsroom is for your buyers, not just the media.
  • 20. 329Visitors expect that the main pages of a website are basically static (i.e., they are not updated often), but they also expect that the news releases and media-targeted pages on a site will reveal the very latest about a company. For many companies, the news release section is one of the most frequently visited parts of the website. Check out your own website statistics; you may be amazed at how many visitors are already reading your news releases and other media pages online. So I want you to do something that many traditional PR people think is nuts. I want you to design your newsroom for your buyers. By building a media room that targets buyers, you will not only enhance those pages as a powerful marketing tool but also make a better media site for journalists. I've reviewed hundreds of newsrooms, and the best ones are built with buyers in mind. This approach may sound a bit radical, but believe me, it works. When news releases are posted on your site, search engine crawlers will find the content, index it, and rank it based on words, phrases, and other factors. Because news release pages update more often than any other part of a typical organization's website, search engine algorithms (tuned to pay attention to pages that update frequently) tend to rank news release pages among the highest on your site, driving traffic there first. “There's no question that a well-organized media room often has higher search results and drives more traffic because of the way the search engines work,” says Dee Rambeau, vice president of customer engagement at PR Newswire. “A news release dynamically builds out a new set of content in your newsroom, with each news release generating its own indexable page, which the search engines all capture. Google and the other search engines love fresh content that relates back to similar content on the other pages of the site. Aggressive companies take advantage of this by sending news releases frequently to get high rankings from the search engines. Frequency has a
  • 21. great deal to do with search engine rankings—if you do 10 news releases, that's great; 20 is better, and 100 is better still.” The Kellogg Company—the world's leading producer of cereal and second-largest producer of cookies, crackers, and savory snacks—uses its newsroom1for search engine optimization (SEO) purposes and as a tool to reach various audiences, including reporters and editors who cover the company. “What we found through our research is that, more and more, our newsroom is extending beyond just media to other stakeholders,” says Stephanie Slingerland, senior manager of corporate communications at the Kellogg Company. “Anyone coming to the site, be it an investor, an NGO or other partner agency, or even a consumer—the newsroom is inviting for them to get the information which may be relevant.” Slingerland has strong partnerships with people who work in other departments at the company and who also provide information to the public. “Our investor relations team are having conversations and engagements with analysts and investors. So, from our partnership with that team, we know what those stakeholders might be looking for. Or, for example, our government relations team are regularly engaging with government and nongovernmental officials. Again, we have a strong partnership with them. We know what they're looking for and can make sure that they have what they might be looking for on our site. The same with our corporate social responsibility team, who engage with agencies and others as part of our philanthropic activities.” Based on what she learns about the needs of the news media and other stakeholders, Slingerland creates the right content, including news releases, fact sheets, news alerts, and more. “Since we are the folks that regularly engage with the media, we know what we're getting asked for over and over, like the fact sheet section,” she says. “And we also know that many people want to know the latest news about the company, but they don't necessarily come to our newsroom every day. So
  • 22. that's why we created our news alerts section, so they opt in to be alerted whenever One important consideration that many marketing and PR people overlook when considering the benefits of a newsroom is that you control the content, not your IT department, webmaster, or anyone else. Youshould design your newsroom as a tool to reach buyers and journalists, and you don't need to take into consideration the rules for posting content that the rest of the organization's site may require. If you build this part of your site using a specialized newsroom content-management application, such as the MediaRoom2product from PR Newswire, you will control a corner of your organization's website that you can update whenever you like using simple tools, and you won't need to request help from anyone in other departments or locations. So start with your needs and the needs of your buyers and journalists, not the needs of those who own the other parts of your organization's website. Start with a Needs Analysis When designing a new newsroom (or planning an extensive redesign), start with a needs analysis. Before you just jump right into site aesthetics and the organization of news releases, take time to analyze how the site fits into your 332larger marketing, PR, and media relations strategy. Consider the buyer persona profiles you built as part of your marketing and PR plan. Talk with friendly journalists so you can understand what they need. Who are the potential users of the newsroom, and what content will be valuable to them? When you have collected some information, build buyers' and journalists' needs into your newsroom. As you work toward starting your design, try to think a bit more like a publisher and less like a marketing and PR person. A publisher carefully identifies and defines target audiences and then develops the content required to meet the needs of each distinct demographic. Graphical elements, colors, fonts, and other visual manifestations of the site are also important but
  • 23. should take a backseat during the content needs analysis process.