Question

create computer program to translate real world descriptions into knowledge representations PS:pick whichever language you prefer:)....

create computer program to translate real world descriptions into knowledge representations

PS:pick whichever language you prefer:). And this is regarding artificial intelligence study.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution

// TextProcess.java

import java.io.File;

import java.io.FileNotFoundException;

import java.util.ArrayList;

import java.util.Scanner;

public class TextProcess {

// method to load all words from a file into an array list

static ArrayList<String> fileToList(File file) {

// creating an array list

ArrayList<String> words = new ArrayList<String>();

// opening file

try {

Scanner scanner = new Scanner(file);

// loops and add each and every word to words list

while (scanner.hasNext()) {

words.add(scanner.next());

}

// closing file

scanner.close();

} catch (FileNotFoundException e) {

// error, the file is not in the same directory

System.out.println("File not found!");

}

return words;

}

// method to extract the words begin with a character ch from an array list

// of words

static ArrayList<String> beginsWith(ArrayList<String> inputList, char ch) {

// creating a list

ArrayList<String> result = new ArrayList<String>();

// looping through each word in input list

for (String word : inputList) {

// checking if word starts with the given character,

// note: this check is case sensitive, if you want to check without

// case sensitivity, convert word to lower case by calling

// word.toLowerCase() and convert ch to lower case by calling

// Character.toLowerCase(ch) just like below commented code

// if(word.toLowerCase().startsWith(""+Character.toLowerCase(ch))

if (word.startsWith("" + ch)) {

result.add(word);

}

}

return result;

}

// method to print all words in a list separated by space

static void print(ArrayList<String> inputList) {

for (String word : inputList) {

System.out.print(word + " ");

}

System.out.println();

}

public static void main(String[] args) {

//

/**

* creating file object. make sure that you have the file cs.txt in the

* root directory of your project. if not, copy the file from the

* folder, go to the IDE (eclipse, netbeans etc) right click on project

* name, click paste, the file will be added. If you fail to do this

* correctly, the file will not be loaded, and this is not mistake in my

* code.

*/

File file = new File("cs.txt");

//loading words

ArrayList<String> words = fileToList(file);

//getting words start with 'a'

ArrayList<String> wordsBeginWithA = beginsWith(words, 'a');

//printing words start with 'a'

print(wordsBeginWithA);

}

}

/*OUTPUT*/

and approach and applications. and algorithms acquisition, and access as a and a and a and as and are abstract, as applications. approaches aspects and and and accessible

Kindly Upvote if Helpful :)
HOPE THIS MAY HELP YOU----------------------

------------------------------THANK YOU---------------------------

Add a comment
Know the answer?
Add Answer to:
create computer program to translate real world descriptions into knowledge representations PS:pick whichever language you prefer:)....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • write computer program to translate the following descriptions into knowledge representations a) Water is a liquid...

    write computer program to translate the following descriptions into knowledge representations a) Water is a liquid between 0 and 100 degrees. b) Water boils at 100 degrees. c) The water in John’s bottle is frozen. d) Perrier is a kind of water. e) John has Perrier in his water bottle. f) All liquids have a freezing point. g) A liter of water weighs more than a liter of alcohol. PS: use whichever language you prefer

  • create computer program to translate the following statements into First Order Logic. You can use whichever...

    create computer program to translate the following statements into First Order Logic. You can use whichever language you prefer. PS: please read the question carefully. It said write a program with whichever language you prefer. a: all cheetahs are fast. Domain: animals; b: some cheetahs are fierce and dangerous. Domain: animals; c: every prime number is odd. Domain: integers; d: all prime numbers except two are odd. Domain: integers; e: all aliens are either green or orange. Domain: living creatures;...

  • C - language please 1. Create a program that does the following, make sure you can...

    C - language please 1. Create a program that does the following, make sure you can complete this before moving to further questions, when compiling add the -Ipthread argument, if you are using gcc use the -pthread argument. Creates two threads, the first uses a function hello world() which prints hello world, the second uses a function goodbye() which prints goodbye. • Each function has a random sleep duration before printing the output - After running your program a few...

  • Write a program in which you create an array of random real numbers with a size...

    Write a program in which you create an array of random real numbers with a size of 10001. The values should fall between 900 and 1000. Using the provided statistics library, calculate all statistical values represented by the functions in the library and output the results. The median value can only be correctly found after the array is sorted. After sorting using the selection sort method, search for the median value using both the linear search and binary search methods....

  • In trying to apply my knowledge in the real world, I am trying to create a...

    In trying to apply my knowledge in the real world, I am trying to create a realistic retirement schedule. However, I am running into difficulties using both a financial calculator as well as our equations from class in doing this. I am trying to do the following: plan a retirement schedule between the ages of 25 and 70, in which I would deposit 20% of my income each year. The income starts at 80,000 with an annual growth rate of...

  • Use your rules for translations and reflections to create a picture. You may do this on paper or using a computer program, such as Geogebra. Follow each step, in o 1. Graph a hexagon with vertices at...

    Use your rules for translations and reflections to create a picture. You may do this on paper or using a computer program, such as Geogebra. Follow each step, in o 1. Graph a hexagon with vertices at (-4, 0), (-2, 0)·(-1,-1), (-2,-2), (-4,-2), and (-5,-1). 2. In the center of the hexagon, label it A. 3. Reflect hexagon A across the y-axis 4. Label the reflected hexagon A 5. Go bak to hexagon A, and translate it using the rule...

  • C++ program: can you help create a autocorrect code using the cpp code provided and the...

    C++ program: can you help create a autocorrect code using the cpp code provided and the words below using pairs, vectors and unordered map: Objectives To practice using C++ std::pair, std::vector, and std::unordered_map To tie together what we've learned into the context of a real-world application used by millions of people every day Instructions For Full Credit You're given a short list of words in known_words_short.txt that contains a handful of very different words. Assume this short list of words...

  • In the C++ programming language write a program capable of playing 3D Tic-Tac-Toe against the user....

    In the C++ programming language write a program capable of playing 3D Tic-Tac-Toe against the user. Your program should use OOP concepts in its design. Use Inheritance to create a derived class from your Lab #9 Tic-Tac-Toe class. You can use ASCII art to generate and display the 3x3x3 playing board. The program should randomly decide who goes first computer or user. Your program should know and inform the user if an illegal move was made (cell already occupied). The...

  • You will create a PYTHON program for Tic-Tac-Toe game. Tic-Tac-Toe is normally played with two people....

    You will create a PYTHON program for Tic-Tac-Toe game. Tic-Tac-Toe is normally played with two people. One player is X and the other player is O. Players take turns placing their X or O. If a player gets three of his/her marks on the board in a row, column, or diagonal, he/she wins. When the board fills up with neither player winning, the game ends in a draw 1) Player 1 VS Player 2: Two players are playing the game...

  • In this assessment, you are required to program an Algorithm-based agent to solve a real-world, which is a challenging case study. This assessment is done individually, and you are required to submit programs and supporting documents in report format. Ple

    You are required to create a robot path planner that is able to find an optimal path to navigate an environment and reach a target. By completing this assessment, you will show your skills on leveraging the best algorithm to solve a simplified real-world problem.The maze can be seen in the image below. It can be seen that there are 12 rows and 24 columns, meaning there is a total of 288 blocks on the map. There are four different...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT