diff --git a/datasets/false_positive_detection_dataset.csv b/datasets/false_positive_detection_dataset.csv index 5493302..920255c 100644 --- a/datasets/false_positive_detection_dataset.csv +++ b/datasets/false_positive_detection_dataset.csv @@ -1,4 +1,4 @@ -copyright,falsePositive +text,label copyright/agent_tests/Unit/test_copyright src/delagent/agent/delagent src/demomod/agent/demomod src/lib/c/fossconfigTest src/lib/c/libdb.patch src/lib/c/reppath src/lib/c/sqlCopyTest src/lib/c/tests/lib-c-Listing.xml src/lib/c/tests/lib-c-Results.xml src/lib/c/tests/testlibs src/lib/cpp/tests/test_l,1 copyright/VERSION-copyright src/spdx2/agent_tests/Functional/spdx-tools-2.0.2-jar-with-dependencies.jar* src/spdx2/agent/version.php src/unifiedreport/agent/version.php src/spdx2/agent/spdx2 src/reportImport/agent/spdx2Import src/reportImport/agent/version.php src/reportImport/agent/reportImport,1 copyright_list src/cli/fo_folder src/cli/fo_nomos_license_list src/cli/fo_wrapper.php src/cli/fossjobs src/cli/fossjobs.1 src/cli/fossjobs.html src/cli/fossjobs.txt src/cli/schema-export src/cli/tests/cli-Xunit.xml src/cli/testupdate2.php src/cli/fo_import_licenses src/cli/fo_usergroup src/cli/fossu,1 diff --git a/utility/false_positive_detection/test.py b/utility/false_positive_detection/test.py index 16f5463..02be70d 100644 --- a/utility/false_positive_detection/test.py +++ b/utility/false_positive_detection/test.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: LGPL-2.1-only from argparse import ArgumentParser - +import os import pandas as pd from sklearn.metrics import classification_report @@ -20,23 +20,23 @@ def main(): # Read the CSV file using Pandas try: - data = pd.read_csv(args.csv_file_path) - print(f"Successfully read the CSV file from: {args.csv_file_path}") + data = pd.read_csv(args.csv_file) + print(f"Successfully read the CSV file from: {args.csv_file}") except FileNotFoundError: - print(f"CSV file not found at: {args.csv_file_path}") + print(f"CSV file not found at: {args.csv_file}") return # Check if the Safaa package is installed in the fossy user pythondeps # Simply check if a directory containing Safaa is inside # /home/fossy/pythondeps - dirs = os.listdir('/home/fossy/pythondeps') - dirs = [d for d in dirs if 'Safaa' in d] - - if len(dirs) == 0: - print(""" - The Safaa package is not installed in the fossy user pythondeps. - Please install by running the post-install script with the --python-experimental flag""") - return + try: + dirs = os.listdir('/home/fossy/pythondeps') + dirs = [d for d in dirs if 'Safaa' in d] + if len(dirs) == 0: + print("Warning: Safaa not found in /home/fossy/pythondeps(This is common for local dev )") + except FileNotFoundError: + print("Skipping check for /home/fossy/pythondeps(folder does not exist locally)") + # Create an instance of the class agent = SafaaAgent() @@ -44,7 +44,7 @@ def main(): predictions = agent.predict(data['text'].to_list()) # Print the predictions - print(classification_report(data['label'].to_list(), predictions)) + print(classification_report(data['label'].astype(str).to_list(), predictions)) if __name__ == "__main__":