Skip to main content

Hello. I'm thinking about how to solve a filter that is defined on this data:

- KASON DJL ?IBABA ?LUKID ?DIPIR ?KELUK ?KOVAR ?PAS PADCA NIFKU BANKO - applies here if the name starts without "?" (KASON) and somewhere in the string a name appears with a "?" (e.g. ?IBABA, ?LUKID.. ) and at the same time the end of the string is a name without "?", so remove "?" throughout the chain. The result is this KASON DJL IBABA LUKID DIPIR KELUK KOVAR PAS PADCA NIFKU BANKO

There will be more such definitions and combinations, does anyone have an idea how to solve it? A regular expression? Or a combination of some transformers?

Thank you

A more complicated variant is this:

?APKO ?DANKO POPKO FERI ?LAKO ?POKO ARN DAN

If my name starts with "?" ( ?APKO ) and somewhere in the string there is a name without "?" ( POPKO, FERI ) and further down the chain a sequence with "?" ( ?LAKO, ?POKO ) followed by names without "?" ( ARN, DAN ), change all values without "?" The result is: APKO DANKO POPKO FERI LAKO POKO ARN DAN


@fmesafe.podpora​ Do you just want to remove all '?'. What would be an example of not wanting to remove the '?' ?


@fmesafe.podpora​ Do you just want to remove all '?'. What would be an example of not wanting to remove the '?' ?

Yes, the first two examples remove all when conditions are met. Example of not removing = keeping.

1st variant: ?APKO ?DANKO POPKO FERI LAKO POKO ARN DAN

2nd variant: APKO DANKO POPKO FERI LAKO ?POKO ?ARN ?DAN

3rd variant: ?APKO ?DANKO POPKO FERI LAKO POKO ?ARN ?DAN

I am attaching a visual aid for a more illustrative example


Yes, the first two examples remove all when conditions are met. Example of not removing = keeping.

1st variant: ?APKO ?DANKO POPKO FERI LAKO POKO ARN DAN

2nd variant: APKO DANKO POPKO FERI LAKO ?POKO ?ARN ?DAN

3rd variant: ?APKO ?DANKO POPKO FERI LAKO POKO ?ARN ?DAN

I am attaching a visual aid for a more illustrative example

I will add:

green lines are unchanged and red lines must have names with "?" remapped to names without "?"


Yes, the first two examples remove all when conditions are met. Example of not removing = keeping.

1st variant: ?APKO ?DANKO POPKO FERI LAKO POKO ARN DAN

2nd variant: APKO DANKO POPKO FERI LAKO ?POKO ?ARN ?DAN

3rd variant: ?APKO ?DANKO POPKO FERI LAKO POKO ?ARN ?DAN

I am attaching a visual aid for a more illustrative example

ADD one last thing: I have the points in the chain as an example in the attachment.


@fmesafe.podpora​ Thanks for the additional explanation I can't see a way to do this using regex (although there probably is). I think I'd make a list attribute using AttributeSplitter and then a small python script (PythonCaller) to process the list. Examples of list attributes and PythonCaller are at the end of the article Transformers for Working with List Attributes


Hi,

thank you for answer. I will try to study it but it seems complicated. I don't know Python, wouldn't there be another solution?


If it were possible to define these conditions in the string "list_of_fixes"

?A B C D? - if my string starts with "?" and at the same time ends with "?", the result is passed (I don't care about B, C)

A B C D - if my string starts without a "?" (A) and at the same time ends without a "?" (D) and at the same time there is no occurrence with "?" ( B C ), the result is passed

?A B C D - if my string starts with "?" and ends without a "?" and at the same time the string does not contain a "?" (B C D, or C D, or D - note), the result is passed

A B C ?D - if my string starts without a "?" ( A ) and ends with a "?" ( ?D ), the result is passed. For example, it could also be A B ?C ?D, or A ?B ?C ?D

NOTE: The number of "?" or names without "?" is not important, the consecutive occurrence is important. The names are as a string, see the attachment. Cut the string in some way and guard the individual pieces according to the definition above.

I will remap the other tracks that will not be passed to a value without "?"

 

A simpler way would be to define not passed:

?A B C ?D E - if the string starts with a "?" (?A), followed by an occurrence without a "?" (B C) and at the same time occurs after ( B C ) sequence with "?" and at the same time without "?" ( ?D, E ), the result is not passed ( for example, if there was no "E" after "?D", the result is passed

A B ?C D E - if the string starts without a "?" And at the same time anywhere in the string there is a "?" ( ?C ) and at the same time the string ends without a "?" (E), the result is not passed. This example is the same as for example: A B C ?D E, or A ?B ?C ?D E etc.


Please, does anyone have an idea, a solution? Thank you


Reply