Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue for isdisjoin() #36

Closed
FuzzyLogic opened this issue Apr 15, 2018 · 2 comments
Closed

Issue for isdisjoin() #36

FuzzyLogic opened this issue Apr 15, 2018 · 2 comments

Comments

@FuzzyLogic
Copy link

Hello,

I am seeing the following output.

from greenery.lego import parse
parse("/etc/.").to_fsm().isdisjoint(parse("/etc/something.").to_fsm())
True

However, I can verify that:

parse("/etc/.").to_fsm().accepts("/etc/something")
True
parse("/etc/something.
").to_fsm().accepts("/etc/something")
True

Am I misinterpreting the semantics of the isdisjoint() method, or is this a bug.

Some background info: I have a similar motivation to yours, I'm interested in the intersection of two regular expressions. However, I am really only interested in knowing whether this intersection is empty. Is there a more efficient way to doing this than calculating 'parse(rx1) & parse(rx2)' and checking if it is empty? I am really trying to to check if two regular expressions that describe file system paths will overlap to some degree.

@qntm
Copy link
Owner

qntm commented Apr 15, 2018

It looks as if Markdown has mangled your examples, but I think you were asking why this happens:

>>> parse("/etc/.*").to_fsm().isdisjoint(parse("/etc/something.*").to_fsm())
True

And yeah, that's a bug. Drilling down slightly we get:

>>> print(parse("/etc/.*").to_fsm() & parse("/etc/something.*").to_fsm())
  name final? / c e g h i m n o s t anything_else
--------------------------------------------------
* 0    False

>>> print(parse(".*").to_fsm() & parse("a.*").to_fsm())
  name final? a anything_else
------------------------------
* 0    False

which are clearly both incorrect. Leave this with me...

qntm added a commit that referenced this issue Apr 18, 2018
@qntm
Copy link
Owner

qntm commented Apr 18, 2018

Fixed with 984b060. Go get greenery version 3.1 to get the fixed version. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants