Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datasets/false_positive_detection_dataset.csv
Original file line number Diff line number Diff line change
@@ -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
Expand Down
26 changes: 13 additions & 13 deletions utility/false_positive_detection/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -20,31 +20,31 @@ 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()

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__":
Expand Down