Hi,
I have a field that contains more than one sentence. I would like to extract
the first sentence from that field - anybody know how this can be done using
the text functions?
Many thanks,
Andrew
|
|
0
|
|
|
|
Reply
|
Andrew
|
1/30/2004 4:51:32 AM |
|
Heya,
Left(field1, Position(field1, ".", 0, 1))
Ta,
Maria
On Fri, 30 Jan 2004, Andrew wrote:
> Hi,
>
> I have a field that contains more than one sentence. I would like to extract
> the first sentence from that field - anybody know how this can be done using
> the text functions?
>
> Many thanks,
> Andrew
>
>
>
Maria Tzortzis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Database Development Officer
Computer Science & Engineering, UNSW
ph: 9385 6887 fax: 9385 5995
www.cse.unsw.edu.au/~mariat/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
0
|
|
|
|
Reply
|
Maria
|
1/30/2004 5:16:48 AM
|
|
In article <oplSb.34116$Wa.27863@news-server.bigpond.net.au>, "Andrew"
<splash@NOSPAM.mac.com> wrote:
> Hi,
>
> I have a field that contains more than one sentence. I would like to extract
> the first sentence from that field - anybody know how this can be done using
> the text functions?
>
> Many thanks,
> Andrew
Usually a sentence is defined to end in a . ! or ? so you need to know
the position of the first one of these characters.
If your original field is called MyText, then the first sentence can be
obtained by a claculated field with a text result along the lines of:
FirstSentence = Left(MyText, Min(Position(MyText, ".", 1, 1),
Position(MyText, "!", 1, 1),
Position(MyText, "?", 1, 1)))
This finds the position of the first . ! and ? and works out which one
comes first unsing the Min function, and then simply takes all the
characters starting on the left of MyText up to and including the . !
or ?
BUT, this won't work if your first sentence was something like:
"Hello, how are you?" asked George as he walked into the room.
The first sentence here ends in 'room.', not 'you?'
You could get around this by ignoring ." !" or ?" but it would get very
messy and may not even be necessary for what you're trying to do.
Helpful Harry
"Hopefully helping harassed humans happily handle handiwork hardships" ;o)
|
|
0
|
|
|
|
Reply
|
Helpful
|
1/30/2004 5:39:46 AM
|
|
This looks like a good calculation that needs one small change:
Just to make sure that things like decimal numbers in a sentence don't
screw you up, instead of parsing for ".", "?", and "!", I'd suggest
adding a space after each punctuation mark (". ", "? ", and "! ")
In article <300120041839463569%helpful_harry@nom.de.plume.com>,
Helpful Harry <helpful_harry@nom.de.plume.com> wrote:
> In article <oplSb.34116$Wa.27863@news-server.bigpond.net.au>, "Andrew"
> <splash@NOSPAM.mac.com> wrote:
>
> > Hi,
> >
> > I have a field that contains more than one sentence. I would like to extract
> > the first sentence from that field - anybody know how this can be done using
> > the text functions?
> >
> > Many thanks,
> > Andrew
>
> Usually a sentence is defined to end in a . ! or ? so you need to know
> the position of the first one of these characters.
>
> If your original field is called MyText, then the first sentence can be
> obtained by a claculated field with a text result along the lines of:
>
> FirstSentence = Left(MyText, Min(Position(MyText, ".", 1, 1),
> Position(MyText, "!", 1, 1),
> Position(MyText, "?", 1, 1)))
>
> This finds the position of the first . ! and ? and works out which one
> comes first unsing the Min function, and then simply takes all the
> characters starting on the left of MyText up to and including the . !
> or ?
>
> BUT, this won't work if your first sentence was something like:
>
> "Hello, how are you?" asked George as he walked into the room.
>
> The first sentence here ends in 'room.', not 'you?'
>
> You could get around this by ignoring ." !" or ?" but it would get very
> messy and may not even be necessary for what you're trying to do.
>
>
>
> Helpful Harry
> "Hopefully helping harassed humans happily handle handiwork hardships" ;o)
|
|
0
|
|
|
|
Reply
|
Abbott
|
1/31/2004 1:17:05 AM
|
|
In article
<abbottnospam-B45B67.18170430012004@news1.west.earthlink.net>, Abbott
Schindler <abbottnospam@nospamkbase.com> wrote:
> This looks like a good calculation that needs one small change:
> Just to make sure that things like decimal numbers in a sentence don't
> screw you up, instead of parsing for ".", "?", and "!", I'd suggest
> adding a space after each punctuation mark (". ", "? ", and "! ")
Good point. You probably should add a space after each character in the
calculation, it would also take care of any sentences with "..." in the
middle of them too. :o)
FirstSentence = Left(MyText, Min(Position(MyText, ". ", 1, 1),
Position(MyText, "! ", 1, 1),
Position(MyText, "? ", 1, 1)))
Although that does introduce the problem of speech sentences,
eg. George said, "Goodbye Jenny." He then left the room.
But this may not be an issue in whatever the original person is trying
to do.
Helpful Harry
"Hopefully helping harassed humans happily handle handiwork hardships" ;o)
|
|
0
|
|
|
|
Reply
|
Helpful
|
1/31/2004 5:06:04 AM
|
|
|
4 Replies
599 Views
(page loaded in 0.088 seconds)
|