saaJamal <aliabbas911 <at> hotmail.com> writes:

U happen to find a way for your problem? I tried a lot for more than a week 
now, but cant do it.

I tried many tutorials but wasnt of any good.

as per the above case study, I need to do is:


1) Allow words to be hyphenated and treat a hyphenated
word as a single word.  However, for those words which are split over two
lines, treat a split word as a single word without the hyphen.

for this i tried:
           fixupHyphens :: [ (Int, Word) ] -> [ (Int, Word ) ]
           fixupHyphens ( (line1, word1):(line2:word2):xs )
           | if (word1, line2) /= line1 = ( line1,word2 ) : fixupHyphens xs
           | otherwise = (line1, word1):(line2:word2): fixupHyphens xs
           fixupHyphens xs = xs

and for including hiphens i added this to the code: 


            splitWords :: Line -> [Word]                        --      a)

            splitWords [] = []
            splitWords  line 
            = takeWhile isLetter line :         --      first word in line
            (splitWords .                       --      split other words
            dropWhile (not.isLetter) .  --      delete separators
            dropWhile isLetter) line    --      other words
            where
             isLetter ch
             =  (('a'<=ch) && (ch<='z'))
              ||        (('A'<=ch) && (ch<='Z'))
              ||      ('-' = ch)


2)Treat a capitalised word (one or more capitals) as being different from the 
word in all lower case (but they should still be sorted alphabetically)unless 
it is at the start of a sentence with only the initial letter capitalised. 


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to