<commit_before>from typing import Iterable

from config import SYFCO_PATH
from helpers.shell import execute_shell, assert_exec_strict
from interfaces.expr import Expr, Signal
from parsing.acacia_parser_helper import parse_acacia_and_build_expr


def _parse_tuple_str(tuple_str) -> Iterable[str]:
    return [s.strip() for s in tuple_str.split(',') if s.strip()]


def get_spec_type(spec_file_name) -> bool:
    rc, out, err = execute_shell('{syfco} -g {spec_file_name}'.format(syfco=SYFCO_PATH,
                                                                      spec_file_name=spec_file_name))
    assert_exec_strict(rc, out, err)
    out_stripped = out.strip().lower()
    assert out_stripped in ['moore', 'mealy'], out_stripped
    is_moore = out_stripped == 'moore'
    return is_moore


def convert_tlsf_to_acacia(spec_file_name) -> (str, str):
    rc, out, err = execute_shell('{syfco} -ins {spec_file_name}'.format(syfco=SYFCO_PATH,
                                                                        spec_file_name=spec_file_name))
    assert_exec_strict(rc, out, err)
    part_text = '.inputs ' + ' '.join(_parse_tuple_str(out.lower()))  # syfco lowers all signal names in props
    rc, out, err = execute_shell('{syfco} -outs {spec_file_name}'.format(syfco=SYFCO_PATH,
                                                                         spec_file_name=spec_file_name))
    assert_exec_strict(rc, out, err)
    part_text += '\n.outputs ' + ' '.join(_parse_tuple_str(out.lower()))  # syfco lowers all signal names in props
    rc, out, err = execute_shell('{syfco} -f acacia {spec_file_name}'.format(syfco=SYFCO_PATH,
                                                                             spec_file_name=spec_file_name))
    assert_exec_strict(rc, out, err)
    ltl_text = out

    return ltl_text, part_text
<commit_msg>fixed bug with the spec translation (my acacia version has OR of less priority than AND while acacia joins ORs over ANDs..)<commit_after>from typing import Iterable

from config import SYFCO_PATH
from helpers.shell import execute_shell, assert_exec_strict
from interfaces.expr import Expr, Signal
from parsing.acacia_parser_helper import parse_acacia_and_build_expr


def _parse_tuple_str(tuple_str) -> Iterable[str]:
    return [s.strip() for s in tuple_str.split(',') if s.strip()]


def get_spec_type(spec_file_name) -> bool:
    rc, out, err = execute_shell('{syfco} -g {spec_file_name}'.format(syfco=SYFCO_PATH,
                                                                      spec_file_name=spec_file_name))
    assert_exec_strict(rc, out, err)
    out_stripped = out.strip().lower()
    assert out_stripped in ['moore', 'mealy'], out_stripped
    is_moore = out_stripped == 'moore'
    return is_moore


def convert_tlsf_to_acacia(spec_file_name) -> (str, str):
    rc, out, err = execute_shell('{syfco} -ins {spec_file_name}'.format(syfco=SYFCO_PATH,
                                                                        spec_file_name=spec_file_name))
    assert_exec_strict(rc, out, err)
    part_text = '.inputs ' + ' '.join(_parse_tuple_str(out.lower()))  # syfco lowers all signal names in props
    rc, out, err = execute_shell('{syfco} -outs {spec_file_name}'.format(syfco=SYFCO_PATH,
                                                                         spec_file_name=spec_file_name))
    assert_exec_strict(rc, out, err)
    part_text += '\n.outputs ' + ' '.join(_parse_tuple_str(out.lower()))  # syfco lowers all signal names in props
    rc, out, err = execute_shell('{syfco} -f acacia -m fully {spec_file_name}'.format(syfco=SYFCO_PATH,
                                                                                      spec_file_name=spec_file_name))
    assert_exec_strict(rc, out, err)
    ltl_text = out

    return ltl_text, part_text

{'fraction_non_alphanumeric': 0.0986910994764398, 'fraction_numerical': 0.0, 'mean_word_length': 2.4485559566787005, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 25, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3278521', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1174, 'n_words': 261}