Commit 313559d4 authored by Hammerschmidt, Myles B. (S&T-Student)'s avatar Hammerschmidt, Myles B. (S&T-Student)
Browse files

Added treecleaner.py

parent d09bd078
### Tree Cleaner for Weka Trees ###
### - Removes empty leaf nodes! - ###
### CS5402 HW7 - M. Hammerschmidt ###
import sys
#Input filename from command line
filename = str(sys.argv[1])
fin = open(filename, 'r')
fout = open("cleaned_"+filename, 'w')
#Remove empty leaf nodes and parenthesis
for line in (fin.readlines()):
l = line.rstrip("\n").split(' (')
if len(l) == 1 or (len (l) > 1 and l[1] != '0.0)'):
fout.write(l[0] + "\n")
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment