reproduce / evaluations /license.py
attilasimko's picture
new evaluations
8ac76ef
from .utils import log
import re
def evaluate(verbose, llm, zip, readme):
log(verbose, "TITLE", "\nEvaluating repository licensing...")
overall = "No"
license_files = [license for license in zip.namelist() if ((("LICENSE" in license) | ("license" in license)) & (len(license.split("/")) == 2))]
if (len(license_files) > 0):
license = zip.open(license_files[0]).read().decode("utf-8")
ans = [row for row in license.split("\n") if row != ""]
if (llm):
license = license
prompt = f"{license}. Please describe this type of license, what it allows and what it doesn't."
ans = llm.predict("HELP", prompt)
log(verbose, "LOG", f"Found license: {ans}")
else:
log(verbose, "LOG", f"Found license file: {license_files[0]}")
overall = "Yes"
return overall
if (readme):
if ("License" in readme):
log(verbose, "LOG", "License found in README.")
overall = "Yes"
return overall
log(verbose, "ERROR", "LICENSE file not found.")
return overall