Text Message Analysis program

Ask questions about projects relating to: computer science or pure mathematics (such as probability, statistics, geometry, etc...).

Moderators: kgudger, bfinio, Moderators

Locked
PerpetuallyConfused
Posts: 2
Joined: Sat Nov 24, 2012 6:04 pm
Occupation: Student:10th grde
Project Question: Java Programming: Text Message Analysis
Project Due Date: 1/15/13
Project Status: I am conducting my research

Text Message Analysis program

Post by PerpetuallyConfused »

My goal is to write a java program that can tell me who sent a text message based on the words/abbreviations that are unique to them. I am almost completely new to programming, so I have no clue on how to do this. I thought about using an If-statement, but I've realized that only works for numerical input. Does anyone know which direction I should go in? All suggestions are welcome :)
dcnick96
Former Expert
Posts: 533
Joined: Wed Jul 25, 2007 7:59 pm

Re: Text Message Analysis program

Post by dcnick96 »

Hello, and welcome to Science Buddies!

I assume you have a list of words/abbreviations that define each person and you will be using your program to search for these pre-defined strings? If so, you can use a switch statement in java. This replaces multiple if...then statements. While most examples of the switch statement uses integers, it is possible to use strings. There are multiple examples on the web of the correct syntax.

I hope this helps. Be sure to write back if you have any other questions. Good luck!
Deana
vysarge
Former Expert
Posts: 65
Joined: Tue Sep 27, 2011 4:56 pm
Occupation: Student: 12th grade
Project Question: Student volunteer.
Project Due Date: N/a: see above.
Project Status: Not applicable

Re: Text Message Analysis program

Post by vysarge »

Hello PerpetuallyConfused!

Dcnick96 gives good advice; a switch statement in Java can definitely help to cut down on code length and complexity. If you separate a String, or text message, into words, that should be much quicker and easier.

I wanted to clear up a bit of a misunderstanding that you seem to have, though- in Java (as well as a few other programming languages such as C++, I believe), it is in fact possible to use string input in an if-statement. If-then statements always contain a boolean value- simply put, a true or false. This allows a bit more flexibility than a switch-case statement, as you can actually ask a String, such as the text message, a few valuable things, such as if it contains another String.

For finding out what functions you can use with each class, like a String, [[the Javadoc]] is probably the most useful resource that I've come across. To the left, you can see a bar containing every class in Java 7, including String; clicking on this link will give you a list of all of the functions. If you're using Java 6 or an earlier version, just Google 'javadoc 6' (or javadoc 5 or similar) and it should be the first link.

[[This function]] in particular should be useful for the function you described.

Hope this helped, and good luck!
-Vysarge

~~~~~~~~~~~~~
Nature uses only the longest threads to weave her patterns, so that each small piece of her fabric reveals the organization of the entire tapestry.
-Richard Feynman
hhemken
Former Expert
Posts: 266
Joined: Mon Oct 03, 2005 3:16 pm

Re: Text Message Analysis program

Post by hhemken »

PerpetuallyConfused,

Most programming languages have a bit of magic called Regular Expressions. Google this:

Code: Select all

java regular expressions
This will allow you to define generic text patterns and quickly see if they are in a string or not. You can even use them to delicately extract substrings with great accuracy and sensitivity. Don't worry if at first you feel clueless. Write a few simple programs on some contrived input data and you'll soon see what's going on.

Trust me, it is pure magic!

Heinz Hemken
Heinz Hemken
Mentor
Science Buddies Expert Forum
PerpetuallyConfused
Posts: 2
Joined: Sat Nov 24, 2012 6:04 pm
Occupation: Student:10th grde
Project Question: Java Programming: Text Message Analysis
Project Due Date: 1/15/13
Project Status: I am conducting my research

Re: Text Message Analysis program

Post by PerpetuallyConfused »

Thank you all so much! I think I'll play with all three methods before I decide which one to use.
raytrent
Former Expert
Posts: 214
Joined: Wed Aug 24, 2005 3:07 pm

Re: Text Message Analysis program

Post by raytrent »

If you want an extra strong challenge, you might look into the idea of creating a Bayesian classifier. This is the kind of algorithm often used to create spam filters for email programs, and they work by training the algorithm on a set of data and applying Bayes' theorem to determine the conditional probability of the text being spam based on things that the user has marked as spam previously.

There's a good starting place here, though it does get a bit technical... there are other sources on the web that you could search for if you find this technique interesting: http://en.wikipedia.org/wiki/Naive_Bayes_classifier
../ray\..
Locked

Return to “Grades 9-12: Math and Computer Science”