"Attribute Filter"

shilaski
shilaski New Altair Community Member
edited November 5 in Community Q&A
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.

Answers

  • TobiasMalbrecht
    TobiasMalbrecht New Altair Community Member
    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
  • shilaski
    shilaski New Altair Community Member
    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? :)

  • TobiasMalbrecht
    TobiasMalbrecht New Altair Community Member
    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
  • 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>