@@ -418,41 +418,43 @@ def metrics_from_file(logger=nil)
418418 metrics
419419 end
420420
421- def generate_metrics_file ( class_count , indiv_count , prop_count )
422- CSV . open ( self . metrics_path , "wb" ) do |csv |
423- csv << [ "Class Count" , "Individual Count" , "Property Count" ]
424- csv << [ class_count , indiv_count , prop_count ]
425- end
426- end
427-
428- def generate_metrics_file2 ( class_count , indiv_count , prop_count , max_depth )
421+ def generate_metrics_file ( class_count , indiv_count , prop_count , max_depth )
429422 CSV . open ( self . metrics_path , "wb" ) do |csv |
430423 csv << [ "Class Count" , "Individual Count" , "Property Count" , "Max Depth" ]
431424 csv << [ class_count , indiv_count , prop_count , max_depth ]
432425 end
433426 end
434427
435428 def generate_umls_metrics_file ( tr_file_path = nil )
436- tr_file_path ||= self . triples_file_path
429+ tr_file_path ||= triples_file_path
437430 class_count = 0
438431 indiv_count = 0
439432 prop_count = 0
433+ max_depth = 0
440434
441435 File . foreach ( tr_file_path ) do |line |
442436 class_count += 1 if line =~ /owl:Class/
443437 indiv_count += 1 if line =~ /owl:NamedIndividual/
444438 prop_count += 1 if line =~ /owl:ObjectProperty/
445439 prop_count += 1 if line =~ /owl:DatatypeProperty/
446440 end
447- self . generate_metrics_file ( class_count , indiv_count , prop_count )
441+
442+ # Get max depth from the metrics.csv file which is already generated
443+ # by owlapi_wrapper when new submission of UMLS ontology is created.
444+ # Ruby code/sparql for calculating max_depth fails for large UMLS
445+ # ontologie with AllegroGraph backend
446+ metrics_from_owlapi = metrics_from_file
447+ max_depth = metrics_from_owlapi [ 1 ] [ 3 ] unless metrics_from_owlapi . empty?
448+
449+ generate_metrics_file ( class_count , indiv_count , prop_count , max_depth )
448450 end
449451
450452 def generate_rdf ( logger , reasoning : true )
451453 mime_type = nil
452454
453455 if self . hasOntologyLanguage . umls?
454456 triples_file_path = self . triples_file_path
455- logger . info ( "Using UMLS turtle file found, skipping OWLAPI parse" )
457+ logger . info ( "UMLS turtle file found; doing OWLAPI parse to extract metrics " )
456458 logger . flush
457459 mime_type = LinkedData ::MediaTypes . media_type_from_base ( LinkedData ::MediaTypes ::TURTLE )
458460 generate_umls_metrics_file ( triples_file_path )
0 commit comments