public override global::System.Data.DataSet Clone() { SubTotalsByDataSet cln = ((SubTotalsByDataSet)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { SubTotalsByDataSet ds = new SubTotalsByDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public void Ejecutar(DUCDataSet midataset, SummaryParameters myParameters, int idEjecution, int maxRepetitions, string theAlgorithm) { //Se establece el Identification de la ejecucion y se crea el directorio de salida var directorioDeSalida = midataset.RougeRootDirectory + @"experimentos\" + idEjecution.ToString("0000"); Directory.CreateDirectory(directorioDeSalida); //Se define el nombre del archivo en el que se colocaran los resultados por medio de los parámetros de ejecución. var theDate = DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + "-" + DateTime.Now.Day.ToString("00") + "-" + DateTime.Now.Hour.ToString("00") + "-" + DateTime.Now.Minute.ToString("00"); var outputFileName = theDate + "-Exp-" + maxRepetitions + "-" + myParameters + ".xlsx"; outputFileName = outputFileName.Replace(",", "."); var directoryList = new List <string>(); directoryList.AddRange(Directory.GetDirectories(midataset.RougeRootDirectory + "documents")); //Tiene la ruta de cada documento directoryList.Sort(); var fileAccount = 0; var allFullNews = new List <string>(); foreach (var fullDirectory in directoryList) //Recorre cada directorio de documentos y hace ... { var lasNoticiasFull = Directory.GetFiles(fullDirectory); allFullNews.AddRange(lasNoticiasFull); } foreach (var fullNews in allFullNews) { fileAccount++; var theFullNews = fullNews; var x = new FileInfo(theFullNews); var thisNews = x.Name; //Deja solo el nombre de la noticia Debug.WriteLine(thisNews + " " + fileAccount); var nombreArchivosCache = midataset.MatricesRootDirectory + thisNews + "-" + myParameters.MyTDMParameters.MinimumFrequencyThresholdOfTermsForPhrase + "-" + myParameters.MyTDMParameters.MinimumThresholdForTheAcceptanceOfThePhrase + "-" + myParameters.MyTDMParameters.TheTFIDFWeight + "-" + myParameters.MyTDMParameters.TheDocumentRepresentation; nombreArchivosCache = nombreArchivosCache.Replace(",", "."); Parallel.For(0, maxRepetitions, repetition => //for (var repetition=0; repetition < maxRepetitions; repetition++) { //if (laNoticia != "LA042190-0060") // continue; // Create the experiment folder If it does not exists var directorioExperimento = directorioDeSalida + @"\" + repetition.ToString("000"); if (!Directory.Exists(directorioExperimento)) { Directory.CreateDirectory(directorioExperimento); } directorioExperimento += @"\systems"; if (!Directory.Exists(directorioExperimento)) { Directory.CreateDirectory(directorioExperimento); } SummarizerAlgorithm summarizer = null; switch (theAlgorithm) { case "ContinuousLexRank": summarizer = new ContinuousLexRank(); summarizer.Summarize(myParameters, theFullNews, nombreArchivosCache); break; case "DegreeCentralityLexRank": summarizer = new DegreeCentralityLexRank(); summarizer.Summarize(myParameters, theFullNews, nombreArchivosCache); break; case "LexRankWithThreshold": summarizer = new LexRankWithThreshold(); summarizer.Summarize(myParameters, theFullNews, nombreArchivosCache); break; case "FSP": ((FSPParameters)myParameters).RandomGenerator = new Random(repetition); summarizer = new FSP(); summarizer.Summarize(myParameters, theFullNews, nombreArchivosCache); break; case "GBHS": ((GBHSParameters)myParameters).RandomGenerator = new Random(repetition); summarizer = new GBHS(); summarizer.Summarize(myParameters, theFullNews, nombreArchivosCache); break; case "SFLA": ((SFLAParameters)myParameters).RandomGenerator = new Random(repetition); summarizer = new SFLA(); summarizer.Summarize(myParameters, theFullNews, nombreArchivosCache); break; } if (summarizer != null) { var contenidoResumenFinal = summarizer.TextSummary; File.WriteAllText(directorioExperimento + @"\" + thisNews, contenidoResumenFinal); } Debug.Write(repetition + ", "); //} // Fin de for }); // Fin de Parallel.For Debug.WriteLine(""); Debug.WriteLine("THREAD :" + Thread.CurrentThread.ManagedThreadId + " NEWS " + thisNews); } Debug.WriteLine("--- EVALUATING ---"); // Se realizan los Calculus de ROUGE para todos los experimentos de la segunda forma (segun normas exactas de DUC 2005) Parallel.For(0, maxRepetitions, experimento => { var directorioExperimento = directorioDeSalida + @"\" + experimento.ToString("000"); Rouge.EvaluateAnExperimentWithAllNewsPartA(midataset.RougeRootDirectory, directorioExperimento); }); var salidaExperimentos = "Exp.\tR1R\tR1P\tR1F\tR2R\tR2P\tR2F\tRLR\tRLP\tRLF\tRSU4R\tRSU4P\tRSU4F\r\n"; var resumenTodosExperimentos = new double[12]; var subtotalesPorGrupoEvaluador = new SubTotalsByDataSet(); for (var experimento = 0; experimento < maxRepetitions; experimento++) { var directorioExperimento = directorioDeSalida + @"\" + experimento.ToString("000"); var resultadoEstaNoticia = new double[12]; Rouge.EvaluateAnExperimentWithAllNewsPartB(midataset.RougeRootDirectory, directorioExperimento, ref resultadoEstaNoticia, ref subtotalesPorGrupoEvaluador); salidaExperimentos += experimento.ToString("00") + "\t"; for (var i = 0; i < 12; i++) { salidaExperimentos += resultadoEstaNoticia[i] + "\t"; resumenTodosExperimentos[i] += resultadoEstaNoticia[i]; } salidaExperimentos += "\r\n"; } salidaExperimentos += "TOTAL\t"; var salidaGlobal = outputFileName + "\t"; for (var i = 0; i < 12; i++) { resumenTodosExperimentos[i] = resumenTodosExperimentos[i] / maxRepetitions; salidaExperimentos += resumenTodosExperimentos[i] + "\t"; salidaGlobal += resumenTodosExperimentos[i] + "\t"; } salidaExperimentos += "\r\n"; salidaGlobal += "\r\n"; File.AppendAllText(@"D:\SalidaGlobal.txt", salidaGlobal); //Thread.Sleep(2000); //GrabarEnExcelExperimentosPorNoticia(midataset.DirectorioRaizRouge, nombreArchivoDeSalida, "TodoExp", salidaExperimentos, true); //foreach (SubTotalsByDataSet.GrupoEvaluadorRow fila in subtotalesPorGrupoEvaluador.GrupoEvaluador.Rows) //{ // fila.Recall = decimal.Divide(fila.Recall, fila.Contador); // fila.Precision = decimal.Divide(fila.Precision, fila.Contador); // fila.Fmeasure = decimal.Divide(fila.Fmeasure, fila.Contador); //} //var listaRouges = new[] { "ROUGE-1", "ROUGE-2", "ROUGE-SU4" }; //foreach (var elRouge in listaRouges) //{ // var salida = "Grupo\tRecall\tPrecision\tFmeasure\r\n"; // foreach (var dataRow in subtotalesPorGrupoEvaluador.GrupoEvaluador.Select("Rouge = '" + elRouge + "'")) // { // var fila = (SubTotalsByDataSet.GrupoEvaluadorRow)dataRow; // salida += fila.Name + "\t" + fila.Recall + "\t" + fila.Precision + "\t" + fila.Fmeasure + "\r\n"; // } // Thread.Sleep(2000); // GrabarEnExcelExperimentosPorNoticia(midataset.DirectorioRaizRouge, nombreArchivoDeSalida, elRouge, salida, true); //} }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); SubTotalsByDataSet ds = new SubTotalsByDataSet(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "EvaluatingGroupDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }