Giter Site home page Giter Site logo

Matching float numbers about drain3 HOT 6 CLOSED

logpai avatar logpai commented on August 22, 2024
Matching float numbers

from drain3.

Comments (6)

davidohana avatar davidohana commented on August 22, 2024

Drain will work well with floats even if you mask only integers because you will get a template like <NUM>.<NUM> for floats in this case.
If you still want a float template, please check that you escape \ properly as \\ in the .ini file.

from drain3.

aguinaldoabbj avatar aguinaldoabbj commented on August 22, 2024

@davidohana Thanks for your reply.

You mean that by using the "default" regexes in drain3.ini ?

By using those default regexes I can get a template with <NUM>.<NUM> just for a few cases.

For example, for this sentence:
Rate of Change Rate 0.572213 Limit 0.1
the drained template is Rate of Change Rate <:*:> Limit <:*:>

And for this sentence:
Deviation Alarm Actual 954.4 Target 3
the drained template is Deviation Alarm Actual <:NUM:>.<:NUM:> Target <:NUM:>

The regex for in the default .ini file is: "((?<=[^A-Za-z0-9])|^)([\\-\\+]?\\d+)((?=[^A-Za-z0-9])|$)". Indeed, it works for both use cases if I use the regex in re.findall() but not with drain.

That's why I'm trying a new regex in the .ini file . I followed your tip and scaped \ in the .ini file:
{"regex_pattern":"(?<![a-zA-Z:])[-+]?\\d*\\.?\\d+", "mask_with": "FLO"},

Still no luck. Both regexes worked flawlessly with re.findall() but not in drain.

I'm trying to figure out what am I doing wrong.

from drain3.

davidohana avatar davidohana commented on August 22, 2024

The order of masks also matters.
Please put float mask before int masks. If some param occurrences are mixed - some float and some int, it can also cause this issue so you may need to capture both in the same mask regex.

from drain3.

aguinaldoabbj avatar aguinaldoabbj commented on August 22, 2024

Ok, I've figured out a regex that matches the floats, so I replaced the default one. But I still don't get why the default one does not work as expected for all my sentences. After a visual inspection, I think the default regex for numbers doesn't match negative floats.

from drain3.

davidohana avatar davidohana commented on August 22, 2024

If masking step produced something like
this is <:NUM:>
this is <:FLO:>

Then Drain step will merge those two into
this is <:*:>

from drain3.

aguinaldoabbj avatar aguinaldoabbj commented on August 22, 2024

If masking step produced something like
this is <:NUM:>
this is <:FLO:>

Then Drain step will merge those two into
this is <:*:>

Yes, I got it. But I was referring to using the default .ini file, with the default regexes, without adding or removing any regex. So I believe my sentences are matched by more than one regex in the default .ini so they get merged in the drain step.

from drain3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.