reproduce / evaluations /license.py
attilasimko's picture
new logging style
69cbe77
raw
history blame
1.1 kB
from .utils import log, model_predict
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[:50]
prompt = f"Q: {license}. This was an excerpt from a license \
file. Do you know the name of this license?"
ans = model_predict(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