"Attribute Filter"

shilaskishilaski Member Posts: 8 Contributor II
edited May 2019 in Help
I am using the ExcelExample Source to bring in a new spreadsheet.  The I am using the Atttribute Filter.  Is there a way to have the parameter string equal 2 strings?  I have it set for the attribute "comments" right now and want to include the group and costs.
Tagged:

Answers

  • TobiasMalbrechtTobiasMalbrecht Moderator, Employee, Member Posts: 294 RM Product Management
    Hi Stacy,

    you mean, you want to filter two attributes simultaneously? This can be done using regular expressions. E.g. if you want to remove two attributes called att1 and att2, you have to set the corresponding parameter to "att1|att2" meaning you want to remove all attributes whose names match either att1 or att2.

    Kinds regards,
    Tobias
  • shilaskishilaski Member Posts: 8 Contributor II
    Tobias,

    Do you have an example? :)

    Here is what I have

    Number                Comment                                                                                        Amount         

    1                          Trailer lights don't work because the connection is loose            $75.08
    2                          Rear lights blink intermittantly                                                        $125.73
    3                          Trailer light stopped working water in the connection                $23.34
    4                          brake light are inop                                                                      $34.56
    5                          Dome light doesn't work                                                              $87.23

    When I pull the data in from an Excel spreadsheet the data will have 3 attributes.....Number Comment and Amount.  I used the attribute filter to just get the comments so I could create word vectors from the comments.  Now I would like to also pull the amount with the comment.  Maybe I need a model shift here? :)

  • TobiasMalbrechtTobiasMalbrecht Moderator, Employee, Member Posts: 294 RM Product Management
    Hi Stacy,

    just use the [tt]AttributeFilter[/tt] and specify "Comment|Amount" as parameter [tt]parameter_string[/tt], or simply take the following code ... ;)

    <operator name="AttributeFilter" class="AttributeFilter">
        <parameter key="condition_class" value="attribute_name_filter"/>
        <parameter key="parameter_string" value="Comment|Amount"/>
    </operator>
    Hope that solves your problem.
    Regards,
    Tobias
  • PatrickPatrick Member Posts: 3 Contributor I
    I've also noticed that you can get fancier with these filters via regex.  I am guessing that the backing implementation is standard java regex.  Here I filter out all fields ending in -FIELD- followed by a single digit.  Filtering out being specified by the "true" value in the "invert_filter" argument.  Otherwise, it'd be an inclusive filter rather than an exclusive one.

            <operator name="FilterNumberedFields" class="AttributeFilter">
                <parameter key="condition_class" value="attribute_name_filter"/>
                <parameter key="parameter_string" value=".*-FIELD-(\d)"/>
                <parameter key="invert_filter" value="true"/>
            </operator>
Sign In or Register to comment.