Connecting Tech Pros Worldwide Help | Site Map

string parser

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 06:00 PM
Raghavendra Mahuli
Guest
 
Posts: n/a
Default string parser

Hi,
I have many strings. I have to sort them. But sorting is not according to
ascii but according to a different format (which keeps varying) . So i can
sort them based on sort-order. It is not much of a problem.

But the complex part is "equivalent-values". it can be defined that "ai" and
"ae" are equivalent-values. Then, while sorting two strings, i have to
consider that "ai" and "ae" are equal......only if they come at same
position in both the strings....
For EX1:
str1 - dfahaesdhfkj
str2 - dfahaisds
In str1, ae appears at position 4 and 5
In str2, ai appears also at position 4 and 5....

So they are equivalent.....And i can replace ae in str1 with ai......


EX2:
str3 - haehasdg
str4 - hhsdaiskdn
In str3, ae appears at position 1 and 2
In str4, ai appears also at position 4 and 5....
So here the rule "equivalent -values" does not apply......So i cant replace
"ae" in str3 with "ai".......


In short, the "equivalent-values" applies only when the
"position-matches"...

To add to that such equivalent values are many......
So can you please suggest me some way of solving this problem ....

regards,
Raghavendra



  #2  
Old July 22nd, 2005, 06:01 PM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: string parser

Raghavendra Mahuli wrote:[color=blue]
> I have many strings. I have to sort them. But sorting is not according to
> ascii but according to a different format (which keeps varying) . So i can
> sort them based on sort-order. It is not much of a problem.
>
> But the complex part is "equivalent-values". it can be defined that "ai" and
> "ae" are equivalent-values. Then, while sorting two strings, i have to
> consider that "ai" and "ae" are equal......only if they come at same
> position in both the strings....
> For EX1:
> str1 - dfahaesdhfkj
> str2 - dfahaisds
> In str1, ae appears at position 4 and 5
> In str2, ai appears also at position 4 and 5....
>
> So they are equivalent.....And i can replace ae in str1 with ai......
>
>
> EX2:
> str3 - haehasdg
> str4 - hhsdaiskdn
> In str3, ae appears at position 1 and 2
> In str4, ai appears also at position 4 and 5....
> So here the rule "equivalent -values" does not apply......So i cant replace
> "ae" in str3 with "ai".......
>
>
> In short, the "equivalent-values" applies only when the
> "position-matches"...
>
> To add to that such equivalent values are many......
> So can you please suggest me some way of solving this problem ....[/color]

First of all, this is not a language problem. Next time please post to
comp.programming if you need some kind of algorithm. Here you only post
if you have a C++ language problem/question/issue/interesting solution.

Second of all, if you do replace every 'ae' in both strings with 'ai',
it will change nothing WRT positional matches. Just try it and see.

Victor
  #3  
Old July 22nd, 2005, 06:01 PM
Till Crueger
Guest
 
Posts: n/a
Default Re: string parser

On Wed, 18 Aug 2004 16:15:36 +0530, Raghavendra Mahuli wrote:
[color=blue]
> Hi,
> I have many strings. I have to sort them. But sorting is not according to
> ascii but according to a different format (which keeps varying) . So i can
> sort them based on sort-order. It is not much of a problem.
>
> But the complex part is "equivalent-values". it can be defined that "ai" and
> "ae" are equivalent-values. Then, while sorting two strings, i have to
> consider that "ai" and "ae" are equal......only if they come at same
> position in both the strings....[/color]
[snip][color=blue]
> In short, the "equivalent-values" applies only when the
> "position-matches"...
>
> To add to that such equivalent values are many......
> So can you please suggest me some way of solving this problem ....[/color]

If you aren't very carefull how you obtain such equivalencies, then the
Problem is not solvable. For example with your equivalency rules above one
can determine that aia<aez of the substitution of ai and ae. However when
you compare afa to those strings you get afa<aia and aez<afa so you get:
afa<aia<aez<afa, which destroys all possibilities of ordering.
Till

--
Please add "Salt and Peper" to the subject line to bypass my spam filter

  #4  
Old July 22nd, 2005, 06:02 PM
Raghavendra Mahuli
Guest
 
Posts: n/a
Default Re: string parser

But ...The rule is that "equivlent values" applies only when u have both
"ae" and "ai" at same position, otherwise we have to sort them like
individual characters....
[color=blue]
>
> First of all, this is not a language problem. Next time please post to
> comp.programming if you need some kind of algorithm. Here you only post
> if you have a C++ language problem/question/issue/interesting solution.
>
> Second of all, if you do replace every 'ae' in both strings with 'ai',
> it will change nothing WRT positional matches. Just try it and see.
>
> Victor[/color]


  #5  
Old July 22nd, 2005, 06:02 PM
Raghavendra Mahuli
Guest
 
Posts: n/a
Default Re: string parser

who said that afa is less that aia??? It will be defined in a dataset.....It
is assured not to be that chaotic as u mentioned...
[color=blue]
>
> If you aren't very carefull how you obtain such equivalencies, then the
> Problem is not solvable. For example with your equivalency rules above one
> can determine that aia<aez of the substitution of ai and ae. However when
> you compare afa to those strings you get afa<aia and aez<afa so you get:
> afa<aia<aez<afa, which destroys all possibilities of ordering.
> Till
>
> --
> Please add "Salt and Peper" to the subject line to bypass my spam filter
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.