Implement a simple automatic language identification system

Assignment Help JAVA Programming
Reference no: EM131967081

Assignment

Project 1: Snake Game

Snake (also called Nibbles) is a classic game whichis played on a rectangular game board. When the game starts, an apple is randomly added to the game board and the snake moves forward. The player uses the 4 arrow keys on the keyboard to change the current direction of the snake. When the snake eats the apple,the body of the snake grows longer, and another apple is randomly added to the gameboard. The game is over if the snake either runs into one of the 4 edges of the game board, or it runs into its own body.

In this project, you will modify the existing Snake game implemented by Jan Bodnar to gain experience with linked list data structures. This game program uses two arrays below to store the x and y coordinates of all joints of the snake:

private final int x[] = new int[ALL_DOTS];
private final int y[] = new int[ALL_DOTS];

You will remove these two arrays from the game program and implement SnakeLinkedList and SnakeNode classes to perform the tasks of these two arrays. Other existing variables and method names in the game program are unchanged (however some method bodies that contain the x and y coordinates can be modified).

The SnakeLinkedList class is either singly-linked list or doubly-linked list class. This class contains the basic variables and methods for a linked list and the snakeMove method to move the snake. You cannot use the existing LinkedList class in Java to implement this class.

The SnakeNode class contains the basic variables and methods for a linked list node, the x and y coordinates and colour (red, blue, white or green). The red head and joints on the body of the snake are instances of this SnakeNode class. Below is the required snake with a red head and 7 joints on its body.

Project 2. Automatic Language Identification

Your task is to implement a simple automatic language identification system that can identify 5 languages (English, French, German, Italian and Spanish) for a sequence of words input by a user at runtime (provided that all words in this sequence are in the same language).

You will implement two modes in the system: learning and identification. In the learning mode, the system learns a specific language by reading a text file that contains several words in that language and outputs a language model, which is a set of probability values of Markov chains (each word is represented as a Markov chain). In the identification mode, the userwill input a word sequence in an unknown language and the system compares this word sequence with 5 language models produced in the learning mode to calculate 5 matching scores. The system will then return the language whose model best matches the word sequence (i.e., the model that has highest matching score). Use Hashtable to store probability values of Markov chains.

The following shows you how to calculate probability values of Markov chains and matching scores.

A word is a sequence of letters. Let S be a set of 4 letters S = {b, e, l, u}. There are many combinations of these letters, for example, belu, beul, blue, bleu, etc. The combination blue is an English word and bleu is a French word.

The occurrences of letters in a word can be regarded as a stochastic process and hence the word can be represented as a Markov chain where letters are states. The occurrence of the first letter in the word is characterized by the initial probability of the Markov chain. The occurrence of other letter given the occurrence of its previous letter is characterized by the transition probability. After analysing several words in a specific language, a set of initial probabilities and transition probabilities will be collected. This set is called language model.

The initial probabilities and the transition probabilities P(letter x → letter y) for a language can be calculated as follows

P(letter x) = number of occurrences of x as the first letter / number of words

P(letter x → letter y) = number of pairs(x,y) / z∈ letter set∑ number of pairs (x,z)

For example, given the word set {added, bee, cab,dad} and the letter set {a, b, c, d, e} in English, the probabilities are calculated as follows:

• Four initial letters in the 4 words are a, b, c and d, so P(a) = P(b) = P(c) = P(d) = 1/4, P(e) = 0

• There are 10 pairs of letters: ad, dd, de, ed, be, ee, ca, ab, da and ad. Sort them as follows: ab, ad, ad, be, ca, da, dd, de, edand ee.

o From these 3 pairs ab, ad, and ad, we have P(a→a) = 0, P(a→b) = 1/3, P(a→c) = 0, P(a→d) = 2/3, P(a→e) = 0.
o From be, we have P(b→a) = P(b→b) = P(b→c) = P(b→d) = 0 and P(b→e) = 1
o From ca, we have P(c→a) = 1 and P(c→b) = P(c→c) = P(c→d) = P(c→e) = 0.
o From da, dd, and de, we have P(d→a) = 1/3, P(d→b) = 0, P(d→c) = 0, P(d→d) = 1/3, P(d→e) = 1/3.
o From edand ee, we have P(e→a) = 0, P(e→b) = 0, P(e→c) = 0, P(e→d) = 1/2, P(e→e) = 1/2.

Assume that we have calculated all language models. Given a sequence of words in an unknown language, now we can calculate the matching score that represents the occurrence of the word sequence in a language. The matching score is simply a product of the initial probability and transition probabilities that are used to generate the word sequence.

For example, the word sequence contains only a word, blue, there are two language models, English and French, and their initial probability and transition probabilities are as follows

Probability

From English model

From French model

P(b)

0.2

0.2

P(b→l)

0.3

0.3

P(l→u)

0.4

0.2

P(u→e)

0.5

0.3

The matching scores of the word blue with the English and French models are as follows

P(blue | English) = P(b) P(b→l) P(l→u) P(u→e) = 0.2*0.3*0.4*0.5 = 0.012
P(blue | French) = P(b) P(b→l) P(l→u) P(u→e) = 0.2*0.3*0.2*0.3 = 0.0036
Since 0.012 > 0.0036, the word blue is identified as an English word.

Hints will be given in lectures and tutorials.

Attachment:- Java-Assignment.rar

Reference no: EM131967081

Questions Cloud

Write appropriate unit tests for the bitcoinpricer class : Write appropriate unit tests for the BitcoinPricer class, ensuring that you have adequate coverage of the possible input space.
Discuss theories of life-span development : For this Assignment, you discuss theories of life-span development by evaluating a theory that seems especially relevant to you and your role as a social worker
Chronological history of individual major life experiences : Provide a chronological history of the individual's major life experiences. Identify specific biological, psychological and sociological influences that shaped.
How could a financial information system be beneficial : How could a financial information system be beneficial to a business with respect to strategic financial management - Explain to your manager, and demonstrate
Implement a simple automatic language identification system : Your task is to implement a simple automatic language identification system that can identify 5 languages (English, French, German, Italian and Spanish).
Description of the social welfare issue : Your letter should include: A description of the social welfare issue, An explanation of how you want the legislator to respond to the issue.
Confidence interval estimate of the mean amount : Develop a 95% confidence interval estimate of the mean amount spent per day by a family of four visiting Niagara Falls (to 2 decimals).
Describe how you would organise an investigation : Explaining the importance of the files you examined. How might they affect a patent case. Provide screen shots of the steps completed in the project
Consider themselves professional baseball fans : 43?% of men consider themselves professional baseball fans. You randomly select 10 men and ask each if he considers himself a professional baseball

Reviews

Write a Review

JAVA Programming Questions & Answers

  Define the methods listed

Write a program that prompts the user to enter 5 integer numbers. Once the user enters the 5 numbers, the program must determine and output the average

  To report the amount of the fine

To report the amount of the fine, which is $25 for the first hour or pan of an hour that the car is illegally parked, plus $10 for every additional hour or part of an hour that the car is illegally parked

  Develop windowed gui java program to demonstrate you can use

For this assignment you are required to develop a Windowed GUI Java Program to demonstrate you can use Java constructs including input/output via GUI interface.

  Java program to implement currency converter

Write a JAVA program that helps the user convert currency. The user will enter the amount in Kuwaiti dinars. The program will print the equivalent amount in US dollar and Euros count his change.

  Modify java application to meet the additional requirements

PRG 420- Modify the Java NON-GUI application using Java NetBeans IDE to meet these additional and changed business requirements company has recently changed its total annual compensation policy to improve sales.

  Develop a similar class hierarchy for animals

Java programmers can use class hierarchies for the purposes of inheritance. Develop a similar class hierarchy for Animals

  Artificial intelligence and computational linguistics

Artificial intelligence and computational linguistics - Andy Warhol Paintings - Write your answer to this problem on the next page, and feel free to tear out this page as a reference. Just for fim, here's the output of the method given as input a p..

  Iness reviews you read on the internet

How much of your purchasing decision is influenced by product/business reviews you read on the Internet? Do you or would you pay for professional

  Create an array of date objects

Create an array of Date objects of size 4. Initialize the array by using a loop. In the loop, use the Scanner.nextLine() method to input a date as a string, convert it to a date by using the toDate() method, and assign the result to an element in ..

  Purpose of method is to find the average of 3 prices

findAveragePrice the purpose of this method is to find the average of 3 prices

  Create a personal lending library tool

Create a personal lending library tool - The user wants to keep track of their movies and games - which ones they own, whether or not they are currently loaned

  Designing a program with a while loop

The section entitled "In the Spotlight", "Designing a program with a while loop" describes the requirements for a project at Chemical Labs, Inc. Write a letter to the Director of Engineering that describe your concerns, if any, regarding these re..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd