<commit_before># This file is part of BenchExec, a framework for reliable benchmarking:
# https://github.com/sosy-lab/benchexec
#
# SPDX-FileCopyrightText: 2022 <NAME>
#
# SPDX-License-Identifier: Apache-2.0

import benchexec.tools.template
import benchexec.result as result

import json
import subprocess


class Tool(benchexec.tools.template.BaseTool2):
    """
    Tool info for Mopsa.
    URL: https://gitlab.com/mopsa/mopsa-analyzer/
    """

    def executable(self, tool_locator):
        return tool_locator.find_executable("mopsa-sv-comp", subdir="bin/")

    def version(self, executable):
        return self._version_from_tool(executable)

    def name(self):
        return "Mopsa"

    def cmdline(self, executable, options, task, rlimits):
        cmd = [executable, "--program", *task.input_files]
        if task.options is not None and "data_model" in task.options:
            cmd += ["--data_model", task.options.get("data_model")]
        if task.property_file:
            cmd += ["--property", task.property_file]
        return cmd

    def determine_result(self, run):
        if run.was_timeout:
            return "TIMEOUT"
        r = run.output
        if r[-1] != "":
            r = r[-1]
        else:
            r = r[-2]
        if r.startswith("true"):
            return result.RESULT_TRUE_PROP
        elif r.startswith("unknown"):
            return result.RESULT_UNKNOWN
        elif r.startswith("ERROR"):
            return result.RESULT_ERROR + r[len("ERROR") :]
        else:
            return result.RESULT_ERROR + f"(unknown: {last})"<commit_msg>Clean and simplify mopsa tool info<commit_after># This file is part of BenchExec, a framework for reliable benchmarking:
# https://github.com/sosy-lab/benchexec
#
# SPDX-FileCopyrightText: 2022 <NAME>
#
# SPDX-License-Identifier: Apache-2.0

import benchexec.tools.template
import benchexec.result as result

class Tool(benchexec.tools.template.BaseTool2):
    """
    Tool info for Mopsa.
    URL: https://gitlab.com/mopsa/mopsa-analyzer/
    """

    def executable(self, tool_locator):
        return tool_locator.find_executable("mopsa-sv-comp", subdir="bin/")

    def version(self, executable):
        return self._version_from_tool(executable)

    def name(self):
        return "Mopsa"

    def cmdline(self, executable, options, task, rlimits):
        cmd = [executable, "--program", *task.input_files]
        if task.options is not None and "data_model" in task.options:
            cmd += ["--data_model", task.options.get("data_model")]
        if task.property_file:
            cmd += ["--property", task.property_file]
        return cmd

    def determine_result(self, run):
        if run.was_timeout:
            return "TIMEOUT"
        r = run.output[-1] or run.output[-2] # last non-empty line
        if r.startswith("true"):
            return result.RESULT_TRUE_PROP
        elif r.startswith("unknown"):
            return result.RESULT_UNKNOWN
        elif r.startswith("ERROR"):
            return result.RESULT_ERROR + r[len("ERROR") :]
        else:
            return result.RESULT_ERROR + f"(unknown: {r})"
{'fraction_non_alphanumeric': 0.1225271218889598, 'fraction_numerical': 0.006062539885130823, 'mean_word_length': 2.5869565217391304, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2097922', 'n_tokens_mistral': 994, 'n_tokens_neox': 973, 'n_words': 226}