Skip to content

Commit

Permalink
Add CLI for PFD verification
Browse files Browse the repository at this point in the history
  • Loading branch information
nemakin authored and chernishev committed Dec 5, 2024
1 parent 8a61f59 commit afc1218
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/cli.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Task(StrEnum):
aucc_verification = auto()
gfd_verification = auto()
nd_verification = auto()
pfd_verification = auto()


class Algorithm(StrEnum):
Expand Down Expand Up @@ -64,6 +65,7 @@ class Algorithm(StrEnum):
gfd_verifier = auto()
egfd_verifier = auto()
naive_nd_verifier = auto()
naive_pfd_verifier = auto()


HELP = 'help'
Expand Down Expand Up @@ -145,6 +147,7 @@ class Algorithm(StrEnum):
14) Verification of exact unique column combinations
15) Verification of approximate unique column combinations
16) Verification of numerical dependencies
17) Verification of probabilistic functional dependencies
If you need other types, you should look into the C++ code, the Python
bindings or the Web version.
Expand Down Expand Up @@ -322,6 +325,13 @@ class Algorithm(StrEnum):
Algorithms: NAIVE_ND_VERIFIER
Default: NAIVE_ND_VERIFIER
'''
PFD_VERIFICATION_HELP = '''Verify whether a given probabilistic functional dependency holds
on the specified dataset. For more information, refer to “Functional Dependency
Generation and Applications in pay-as-you-go data integration systems” by
Daisy Zhe Wang et al.
Algorithms: NAIVE_PFD_VERIFIER
Default: NAIVE_PFD_VERIFIER
'''
PYRO_HELP = '''A modern algorithm for discovery of approximate functional
dependencies. Approximate functional dependencies are defined in the
“Efficient Discovery of Approximate Dependencies” paper by S.Kruse and
Expand Down Expand Up @@ -498,6 +508,11 @@ class Algorithm(StrEnum):
a given numerical dependecy holds. For more information refer to "Efficient
derivation of numerical dependencies" by P. Ciaccia et al.
'''
NAIVE_PFD_VERIFIER_HELP = '''A straightforward algorithm for
verifying whether a given probabilistic functional dependency holds. For
more information, refer to “Functional Dependency Generation and Applications
in pay-as-you-go data integration systems” by Daisy Zhe Wang et al.
'''

OPTION_TYPES = {
str: 'STRING',
Expand Down Expand Up @@ -526,6 +541,7 @@ class Algorithm(StrEnum):
Task.aucc_verification: AUCC_VERIFICATION_HELP,
Task.gfd_verification: GFD_VERIFICATION_HELP,
Task.nd_verification: ND_VERIFICATION_HELP,
Task.pfd_verification: PFD_VERIFICATION_HELP
}

ALGO_HELP_PAGES = {
Expand Down Expand Up @@ -560,6 +576,7 @@ class Algorithm(StrEnum):
Algorithm.egfd_verifier: GFD_VERIFIER_HELP,
Algorithm.apriori: APRIORI_HELP,
Algorithm.naive_nd_verifier: NAIVE_ND_VERIFIER_HELP,
Algorithm.naive_pfd_verifier: NAIVE_PFD_VERIFIER_HELP
}

TaskInfo = namedtuple('TaskInfo', ['algos', 'default'])
Expand Down Expand Up @@ -602,6 +619,8 @@ class Algorithm(StrEnum):
Algorithm.naive_gfd_verifier),
Task.nd_verification: TaskInfo([Algorithm.naive_nd_verifier],
Algorithm.naive_nd_verifier),
Task.pfd_verification: TaskInfo([Algorithm.naive_pfd_verifier],
Algorithm.naive_pfd_verifier),
}

ALGOS = {
Expand Down Expand Up @@ -636,6 +655,7 @@ class Algorithm(StrEnum):
Algorithm.egfd_verifier: desbordante.gfd_verification.algorithms.EGfdValid,
Algorithm.apriori: desbordante.ar.algorithms.Apriori,
Algorithm.naive_nd_verifier: desbordante.nd_verification.algorithms.NDVerifier,
Algorithm.naive_pfd_verifier: desbordante.pfd_verification.algorithms.PFDVerifier
}


Expand Down Expand Up @@ -677,7 +697,7 @@ def check_error_option_presence(task: str | None, error: str | None) -> None:


def check_pfd_error_measure_option_presence(task: str | None, error_measure: str | None) -> None:
if task == Task.pfd and error_measure is None:
if task in (Task.pfd, Task.pfd_verification) and error_measure is None:
click.echo(f"ERROR: Missing option '{PFD_ERROR_MEASURE}'.")
sys.exit(1)

Expand Down Expand Up @@ -761,6 +781,14 @@ def get_algo_result(algo: desbordante.Algorithm, algo_name: str, provided_option
result = (f'Exact unique column combination does not hold, but '
f'instead approximate unique column combination '
f'holds with error = {error}')
case Algorithm.naive_pfd_verifier:
error = algo.get_error()
if error == 0.0:
result = 'Exact functional dependency holds'
else:
result = (f'Exact functional dependency does not hold, but '
f'instead probabilistic functional dependency '
f'holds with error = {error}')
case Algorithm.icde09_mfd_verifier:
result = algo.mfd_holds()
case algo_name if algo_name in TASK_INFO[Task.fd].algos:
Expand Down

0 comments on commit afc1218

Please sign in to comment.