Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 9d3483d2 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

Added data/logAnalysis for extracting data from log files

parent 539bf390
No related branches found
No related tags found
No related merge requests found
# Open file
# Read line by line those containing ^.* main [^\t]*
# as W\ (a\ =\ v{;})*
# To store as a line
# Average (as float) all those lines with the same W
import re
import pandas as pd
import pysake.data.tableDisplay as tdis
def parseLogfile( filename, cols ):
"""
Parse a log file and returns a dataframe with average attribute values aggregated by modality
Parameters:
:filename -- the name (path) of the log file
:cols -- the list of column names of the resulting table
"""
logfile = open( filename, 'r' )
entries = []
for line in logfile:
# Unsure it will always be DEBUG...
twosides = re.split(r'^.*DEBUG main [^\s]*\s+',line.strip())
if len(twosides) > 1:
tug = re.split( r"\s", twosides[1].strip(), maxsplit=1 )
listatt = re.findall( r'\s*\w+ = ([^;]*)[;]?', tug[1] )
entries += [ [tug[0]]+listatt ]
logfile.close()
df = pd.DataFrame( entries, columns=cols )
tdis.typeTableColumns( df )
df = df.groupby(cols[0]).mean()
return df
......@@ -142,5 +142,5 @@ def formatTableStandard( style, size=0 ):
dict(selector="tr:nth-child("+str(size)+"n)", props=barbelow)
]
style.set_table_styles( standardStyles )
style.format({'Size': '{:0.0f}','Success rate': '{:0.2f}','Incoherence': '{:0.2f}','Semantic precision': '{:0.2f}','Semantic F-measure': '{:0.2f}','Semantic recall': '{:0.2f}','Convergence': '{:0.0f}'})
style.format({'Size': '{:0.0f}','Success rate': '{:0.2f}','Incoherence': '{:0.2f}','Semantic precision': '{:0.2f}','Semantic F-measure': '{:0.2f}','Semantic recall': '{:0.2f}','Convergence': '{:0.0f}'} )
return style
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment