Ivan Amarquaye | 11 May 17:42
Picon
Favicon

dropping hyphens and \n in words

Generally a hyphen is written at the end of the sentance when moving on to the next line and i managed to achieve this in haskell by using the "\n"- newline which places an index word in the next line i.e. if the words appear indexed like this...([1]),[mangoes] and a hyphen is applied, it becomes ([1],[mang-oes]) and it is valid in my function as i made it accept hyphens as part of a single word.
 
Now my problem is this...I'm assuming that the hyphen normally comes at the end of a sentence like this: "there are so many guys ravis-hing our women" and this can be demonstrated in haskell by "\n" which places the words or characters following it in a new line like this:
input: makeIndex"there are so many guys ravis\nhing our women" and output is: (([1],[there]),([1],[ravis]),([2],[hing])) where 1 means the first line and 2 the next.
 
Now i want to write a function that would take away the hyphen and \n  from all the words supposed to end on the first line and continue on the next and make all appear on the first line like this: all words in this form: "chip-\nheater" should become "chipheater". hope i can get some guidance on doing this.

Connect to the next generation of MSN Messenger  Get it now!
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Picon
Favicon

Re: dropping hyphens and \n in words


On 2008 May 11, at 11:47, Ivan Amarquaye wrote:

Now my problem is this...I'm assuming that the hyphen normally comes at the end of a sentence like this: "there are so many guys ravis-hing our women" and this can be demonstrated in haskell by "\n" which places the words or characters following it in a new line like this:
input: makeIndex"there are so many guys ravis\nhing our women" and output is: (([1],[there]),([1],[ravis]),([2],[hing])) where 1 means the first line and 2 the next. 

Somewhat unrelated point:  breaking between "s" and "h" would be peculiar for English because they're components of a digraph.

Now i want to write a function that would take away the hyphen and \n  from all the words supposed to end on the first line and continue on the next and make all appear on the first line like this: all words in this form: "chip-\nheater" should become "chipheater". hope i can get some guidance on doing this.


Hint:  \n may look funny, but it is a character like any other and can be used in pattern matching.

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery <at> kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery <at> ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Achim Schneider | 11 May 19:58
Picon

Re: dropping hyphens and \n in words

Ivan Amarquaye <amarquaye.ivan <at> hotmail.com> wrote:

> 
> Generally a hyphen is written at the end of the sentance when moving
> on to the next line and i managed to achieve this in haskell by using
> the "\n"- newline which places an index word in the next line i.e. if
> the words appear indexed like this...([1]),[mangoes] and a hyphen is
> applied, it becomes ([1],[mang-oes]) and it is valid in my function
> as i made it accept hyphens as part of a single word. Now my problem
> is this...I'm assuming that the hyphen normally comes at the end of a
> sentence like this: "there are so many guys ravis-hing our women" and
> this can be demonstrated in haskell by "\n" which places the words or
> characters following it in a new line like this: input:
> makeIndex"there are so many guys ravis\nhing our women" and output
> is: (([1],[there]),([1],[ravis]),([2],[hing])) where 1 means the
> first line and 2 the next. Now i want to write a function that would
> take away the hyphen and \n  from all the words supposed to end on
> the first line and continue on the next and make all appear on the
> first line like this: all words in this form: "chip-\nheater" should
> become "chipheater". hope i can get some guidance on doing this.
> 
Excuse my bluntness, but I utterly fail to make sense of this.
Reformulating your understanding of it would surely be beneficial.

--

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 
Chaddaï Fouché | 11 May 21:10
Picon

Re: Re: dropping hyphens and \n in words

2008/5/11 Achim Schneider <barsoap <at> web.de>:
>  Excuse my bluntness, but I utterly fail to make sense of this.
>  Reformulating your understanding of it would surely be beneficial.

He has a routine that gives him a list of words classified by line,
and he want the hyphens to be accounted for.
So that :
"Hello mis-
ter world !"
gives [(1,["Hello","mister"]),(2,["world","!"])]

--

-- 
Jedaï
Achim Schneider | 11 May 21:30
Picon

Re: dropping hyphens and \n in words

"Chaddaï Fouché" <chaddai.fouche <at> gmail.com> wrote:

> 2008/5/11 Achim Schneider <barsoap <at> web.de>:
> >  Excuse my bluntness, but I utterly fail to make sense of this.
> >  Reformulating your understanding of it would surely be beneficial.
> 
> He has a routine that gives him a list of words classified by line,
> and he want the hyphens to be accounted for.
> So that :
> "Hello mis-
> ter world !"
> gives [(1,["Hello","mister"]),(2,["world","!"])]
> 
Well, that's either a relatively complex hand-written recursion, or you
map a predicate that tests for hyphens over the list and zip it with the
original, offset by one, and then map it all into the result.

--

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

Gmane