SKIP TO THE BOTTOM IF YOU JUST WANT TO HELP ME WITH SOMETHING PLEASE!!Project details:
Quote
CS 2250 Project 1 Fall 2012
Your first project is to write a program which reads from standard input a series of lines of
Latin nouns and adjectives and to output to the screen their declination.
In many languages, nouns (and adjectives) are declined into a variety of forms [called ”cases”]
to show their function in the sentence. In Latin, there are 5 cases: nominative [subject],
genitive [possession], dative [indirect object], accusative [direct object], and ablative [adverbial
usages] with 2 numbers: singular and plural. In English, only pronouns have any cases;
for nouns and adjectives, we only distinguish number.
The input will consist of lines with 2 blank-separated forms of a noun or an adjective: the
nominative singular and the genitive singular. The final line will contain the word ”QUIT”
(all in capitals).
If the genitive ends in ”ae”, the word in the in First Declination. The stem is found by
removing the ”ae” from the genitive. The cases are formed by adding the following endings
to the stem
Singular Plural
Nom. [given] ae
Gen. ae arum
Dat. ae is
Acc. am as
Abl. a is
If the genitive ends in ”i”, the word in the in Second Declination. The stem is found by
removing the ”i” from the genitive. There are 2 possibilities: nominative ends in ”um” and
nominative end in ”us” or ”r”. The cases are formed by adding the following endings to the
stem:
-us or -r Words -um Words
Singular Plural Singular Plural
Nom. [given] i [given] a
Gen. i orum i orum
Dat. o is o is
Acc. um os um a
Abl. o is o is
basically he gives us an input file that might look like
xxxx xxxx
yyyy yyyy
zzzz zzzz
QUIT
he will compile our code and input the file as such
g++ project.cpp < inputs
so the idea is that if he gives us, for example, the line
Code
vir viri
The code needs to do this:
read the line into a string. It should recognize the first word as the
NOM. SINGULAR and the second as the
GEN. SINGULARfrom there, we need to achieve the
STEM. We do this by taking the
GEN SING and removing the part at the end. In this case, viri, the 'i' is the end, so we remove it and the stem becomes 'vir'.
It should be noted there are 3 possible cases for this.
The
GEN. SING. ends in either 'ae', 'us OR r' & 'um'
Once we figure out which, we list out the 5 latin forms of the word.
For the vir example, it would be
vir viri
viri virorum
viro viris
virum viros
viro viris
------------------------------------------------------------------------------------------------------------------------------------------------------
Now, that aside, I need some help doing the very first task. I can probably figure out the string manipulation stuff, but I need a good way to read the first line of the input document, separate the two words into two different strings? Then be able to mess around with them. I never really learned how to do this in 1250 and the prof didn't really tell us how to do it either. Basically, the 2nd word is the one I need the most I think.
Can someone shed some light on how to do this? (The words will most likely be separated with a single space)
I think what I want to do is:
Use a while loop to read line by the line the document.
Put the 2 words of a line into 2 different strings. Use the 2nd string to check to see if the word ends in 'ae' or 'i'
If it ends in i, it also checks string 1 to see if it ends in 'us' or 'r' or to see if it ends in 'um'
Once we get through all of these statements, we will take the word contained in string2, delete the ending characters (i or ae) and then copy that into a new string called STEM.
Depending on what is true, I will then (probably) perform some minor string manipulations and print out each line
ex:
NOM [string1] [STEM+i]
GEN [string2] [STEM+orum]
DAT [stem + o] [stem + is]
ACC [stem + um] [stem + os]
ABL [stem + o] [stem + is]
More questions:
Can I use the same variable names for the loop?
Like if I do
string term1,term2,stem;
If I put a word into term1 and term 2 and find stem, print them out, then go to line 2....
will the compiler like, add the new line terms into term1 and term2 or will it be smart enough to clean them out?
Poorly worded on my part but basically wondering how this would all work.
This post was edited by Eep on Sep 10 2012 02:19pm