Stringscan



Creates a new StringScanner object to scan over the given string. Dup argument is obsolete and not used now. A lipogram is a kind of 'writing with constraints' consisting of writing paragraphs or longer works in which a particular letter or group of letters is missing, usually a common vowel, the most common in English being e. StringScan II. Simple Lightweight Manual X-Y scanner. 30in. (0.76m x 0.76m) scan area. Suction Feet or (Optional) Magnetic feet. Liquid feed. Versatile and portable. 0.020in. (0.50mm) Resolution Works with: Raptor Imaging flaw detector & BondHub.

Creates a new StringScanner object to scan over the given string. Dup argument is obsolete and not used now.

  • Practice working with loops.
  • Further practice with conditional statements.
  • More practice working with Strings.
Background

A lipogram is a kind of 'writing with constraints' consisting of writingparagraphs or longer works in which a particular letter or group of letters ismissing, usually a common vowel, the most common in English being e. A lipogramauthor avoiding e then only uses the 25 remaining letters of the alphabet. Here is an example of a lipogram that avoids the letter e:

  • An author must submit to an awful handicap, allowing only consonants and A, I , O and U this is ordinarily a quorum of six fours and two.

Writing a lipogram is a trivial task for uncommon letters like z, w, or x, but itis much more difficult for common letters like E.

A palindrome is a word, phrase, number or any other sequence whichhas the property of reading the same in either direction. Adding spaces andpunctuation is permitted. The word 'palindrome' comes from the Greek wordspalin ('back') and dromos ('racecourse').

Here are some examples of palindromes:

  • Bob
  • ABBA
  • Madam, I'm Adam.
  • Too hot to hoot.
  • Doc, note, I dissent. A fast never prevents a fatness. I diet on cod.
  • Rats live on no evil star.
  • Rise to vote sir!
  • Race fast safe car.
  • Ma is as selfless as I am.
  • May a moody baby doom a yam.

An alliteration is a stylistic device in which successive words beginwith the same letter (or sometimes the same sound). In our case we will onlyconsider alliterations that follow the 'same letter' property. It is often thecase that short words (three letters or less) are inserted to make the sentencemake sense.

Here are some examples of alliterations:

  • alliteration's artful aid
  • Peter parker's poems are pretty
  • Round the rugged rock the ragged rascal ran
  • Peter Piper picked a peck of pickled peppers

Your program will ignore words that are three letters or less when searchingfor alliterations. For this program, you may assume that the first word of thesentence is at least 4 letters long.

In this lab, you will complete three 'Mini Labs' as separate java programsthat ask the user to enter an Englishsentence, word or phrase, and then tests the input for the various properties.

Your programs will allow the user to enter a sentence, andwill respond by telling the user the answer to one of the following questions:

  • Is the input a lipogram avoiding a given letter?
  • Is the input a palindrome?
  • Is the input an alliteration?

An example of your programs' interactions are shown below:

LIPOGRAM DETECTOR
Please enter a sentence: Peter parker's poems are pretty
Please enter a letter to avoid: S
Your input was: 'Peter parker's poems are pretty'
The input is not a lipogram avoiding S.
LIPOGRAM DETECTOR
Please enter a sentence: Able was I ere I saw Elba
Please enter a letter to avoid: J
Your input was: 'Able was I ere I saw Elba'
The input is a lipogram avoiding J.
PALINDROME DETECTOR
Please enter a sentence: Peter parker's poems are pretty
Your input was: 'Peter parker's poems are pretty'
The input is not a palindrome.
PALINDROME DETECTOR
Please enter a sentence: Able was I ere I saw Elba
Your input was: 'Able was I ere I saw Elba'
The input is a palindrome.
ALLITERATION DETECTOR
Please enter a sentence: Peter parker's poems are pretty
Your input was: 'Peter parker's poems are pretty'
The input is an alliteration.
ALLITERATION DETECTOR
Please enter a sentence: Able was I ere I saw Elba
Your input was: 'Able was I ere I saw Elba'
The input is not an alliteration.

The prelab below will be submitted as a Sakai Quiz. To receive pre-lab points the quiz should be completed before the start of your lab session.

To prepare for this lab assignment, we suggest you watch the video, Text Analyzer.

  1. Review the proper use of the Scanner object for breaking up a String into words. A brief desciption is included in the Appendix below. The Text Analyzer Example video describes a similar technique using the StringTokenizer class. However, we recommend that you use the Scanner instead, because StringTokenizer is no longer recommended for use (deprecated).
  2. Complete the Sakai Quiz questions to categorize 'sentences' by their properties. Here are some examples:

    SentencePalindromeAlliterationLipogram
    avoiding E
    Lipogram
    avoiding S
    noonXXX
    detartratedXX
    Anxious ants avoid the anteater's advances.X
    Sir, I eye Iris.X

  3. Prepare a pseudocode algorithm for determining whether a String is an alliteration and submit it through the Sakai Quiz.
  4. Prepare a pseudocode algorithm for determining whether a String is a palindrome and submit it through the Sakai Quiz. Think about how you will be able to avoid spaces and punctuation. (Hint: a pre-processing pass of the String to remove these things might be helpful.)
On-line Lab Procedure
  1. Your lab will be conducted at the usual time using Zoom.
  2. Create a Lab04 directory on your computer. Create a class named Lipogram and save it in a file named Lipogram.java and begin writing that mini-lab. Compile and test as you go. If you're using the online compiler, be sure to download and save your file.
  3. Create a class named Palindrome and save it in a file named Palindrome.java and begin writing that mini-lab based on the pseudocode developed as part of the pre-lab.
  4. Create a class named Alliteration and save it in a file named Alliteration.java and begin writing that mini-lab based on the pseudocode developed as part of the pre-lab.
  5. Fill out your 'Lab CAT.'
  6. Do Post-Lab tasks as time permits.
  7. Be sure to save your files as you go!
  1. Thoroughly test your programs!
  2. For this lab, creativity is optional (it's been a tough couple of weeks!), but you can earn up to 10 extra credit points if you're feeling creative. Some suggestions include:
    • Fix your alliteration test so that it works even on sentences where the first word or words is/are three letters or less. (5 points)
    • Add a sentinel based loop that allows the user to continue entering sentences to be tested in the same way until the user enters the single word: 'quit.' (5 points)
    • Add some additional statistics about each sentence including the number of words, average word length, and longest word. (5 points)
  3. Note: Creativity Extra-Credit points are only awarded after all required components are working correctly. Also, credit will only be given extre credit for documented creativity so be sure specify your creativity in your program header!

  4. When you are sure that your programs are working, submit Lipogram.java, Palindrome.java and Alliteration.java to https://www.cs.plu.edu/submit/ sometime before the due date.
  5. You do not need to submit a printout or coversheet.
Stringscan
Grading

Your lab will be graded on the following:

Pre-lab

  • (10 points) Graded in Sakai Pre-lab Quiz

In-lab

  • (10 points) Participation in lab in one or more ways: This can mean joining the lab session in Zoom, working with a partner in the Zoom breakout rooms,finding a partner to work with remotely outside of class, posting or answering questions in Piazza.
  • (5 points) Lab CAT submitted
Submission
  • (15 points) Style - lab header, inline comments, indentation, meaningful variable names, etc.
  • (20 points) Lipogram.java compiles, runs, produces the correct output, and output is formatted correctly.
  • (20 points) Palindrome.java compiles, runs, produces the correct output, and output is formatted correctly.
  • (20 points) Alliteration.java compiles, runs, produces the correct output, and output is formatted correctly.
Extra-credit Creativity
  • (10 points) Something extra that requires some creativity or individual studyworth up to 10 extra credit points for this lab.
  1. It will be helpful in this program to use a Scanner object to help break up a String into parts based on spaces. Here is an example of how it can be used:

    The output of the above code would be:

    This
    is
    an
    example.
  2. Some useful methods in the Character class (look them up in the docs):
    Character.isLetter()
    Character.isLetterOrDigit()
    Character.toLowerCase()
    Character.isLowerCase()
    Character.isUpperCase()
    Character.toUpperCase()

Description

Stringscan

This is a implementation of the JSON specification according to RFC 4627. You can think of it as a low fatalternative to XML, if you want to store data to disk or transmit it over anetwork rather than use a verbose markup language.

Starting from version 1.0.0 on therewill be two variants available:

  • A pure ruby variant, that relies on the iconv and the stringscan extensions, which are both part of the ruby standard library.
  • The quite a bit faster (see the documentation) C extension variant, which is in parts implemented in C and comes with its own unicode conversion functions and a parser generated by the Ragel State Machine Compiler.

Both variants of the JSON generator escape all non-ASCII an controlcharacters with uXXXX escape sequences, and support UTF-16 surrogate pairsin order to be able to generate the whole range of unicode code points. Thismeans that generated JSON text is encoded as UTF-8 (because ASCII is a subsetof UTF-8) and at the same time avoids decoding problems for receivingendpoints, that don't expect UTF-8 encoded texts. On the negative side thismay lead to a bit longer strings than necessarry.

It's also easy to extend JSON data types for arbitrary Ruby classes (includingyour own) like this:

Now Range instances can be serialized/deserialized:

A lot of additional information about JSON can be found Douglas Crockford's JSONsite.

Installation

The library can be installed via rubygems:

If you have to use the pure variant, you can use:

Strings Can Do It All

The gem and the source archive can also be downloaded directly from rubyforge.org.

Usage

If you require JSON like this:

JSON first tries to load the extension variant. If this fails, the pure variantis loaded and used.

To determine, which variant is active you can use the follwing methods: Things to download on macbook pro.

  • Ext variant:
  • Pure variant:

If you want to enforce loading of a special variant, use

to load the extension variant. Or use

to use the pure variant.

You can choose to load a set of common additions to ruby core's objects if you

To get the best compatibility to rails' JSON implementation, you can

Strings Can Use Double Or Single Quotes

Both of the additions attempt to require 'json' (like above) first, if it has not been required yet.

Author

Florian Frank <flori@ping.de>

Strings Can Store C#

License

Rails Stringscanner

This is software is distributed under the same license as Ruby itself. See http://www.ruby-lang.org/en/LICENSE.txt.