Check whether a predicate is grammarically correct. Args: name: str: name of the predicate args: list[str]: args of the predicate Returns: bool: whether the predicate arg count is valid.
(name: str, args: list[str])
| 314 | |
| 315 | |
| 316 | def check_valid_args(name: str, args: list[str]) -> bool: |
| 317 | """Check whether a predicate is grammarically correct. |
| 318 | |
| 319 | Args: |
| 320 | name: str: name of the predicate |
| 321 | args: list[str]: args of the predicate |
| 322 | |
| 323 | Returns: |
| 324 | bool: whether the predicate arg count is valid. |
| 325 | """ |
| 326 | if name == 'perp': |
| 327 | if len(args) != 4: |
| 328 | return False |
| 329 | a, b, c, d = args |
| 330 | if len({a, b}) < 2: |
| 331 | return False |
| 332 | if len({c, d}) < 2: |
| 333 | return False |
| 334 | elif name == 'para': |
| 335 | if len(args) != 4: |
| 336 | return False |
| 337 | a, b, c, d = args |
| 338 | if len({a, b, c, d}) < 4: |
| 339 | return False |
| 340 | elif name == 'cong': |
| 341 | if len(args) != 4: |
| 342 | return False |
| 343 | a, b, c, d = args |
| 344 | if len({a, b}) < 2: |
| 345 | return False |
| 346 | if len({c, d}) < 2: |
| 347 | return False |
| 348 | elif name == 'coll': |
| 349 | if len(args) != 3: |
| 350 | return False |
| 351 | a, b, c = args |
| 352 | if len({a, b, c}) < 3: |
| 353 | return False |
| 354 | elif name == 'cyclic': |
| 355 | if len(args) != 4: |
| 356 | return False |
| 357 | a, b, c, d = args |
| 358 | if len({a, b, c, d}) < 4: |
| 359 | return False |
| 360 | elif name == 'eqangle': |
| 361 | if len(args) != 8: |
| 362 | return False |
| 363 | a, b, c, d, e, f, g, h = args |
| 364 | if len({a, b, c, d}) < 3: |
| 365 | return False |
| 366 | if len({e, f, g, h}) < 3: |
| 367 | return False |
| 368 | return True |
| 369 | |
| 370 | |
| 371 | def try_translate_constrained_to_construct(string: str, g: gh.Graph) -> str: |
no outgoing calls
no test coverage detected