public static string ToHtmlTable ( this IEnumerable <OpinionMiningTuple> opinionMiningTuples, HttpServerUtility server, OffsetsProcessor offsetsProcessor, string originalText, OffsetCreationXmlTypeEnum offsetCreationXmlType ) { if (!opinionMiningTuples.Any()) { return(ANYTHING_ISNT_PRESENT); } var sb = new StringBuilder(TABLE_START); var number = 0; foreach (var tuple in opinionMiningTuples) { var offsetsString = offsetsProcessor.CreateOffsetsString(tuple.GetSentence()); var xdoc = default(XDocument); var html = default(string); switch (offsetCreationXmlType) { case OffsetCreationXmlTypeEnum.Flat: xdoc = OffsetsString2XDocumentConverter.ConvertToFlat(originalText, offsetsString); html = xdoc.MakeOffsetsFlatXslt(server); break; case OffsetCreationXmlTypeEnum.Hierarchy: xdoc = OffsetsString2XDocumentConverter.ConvertToHierarchy(originalText, offsetsString); html = xdoc.MakeOffsetsHierarchyXslt(server); break; default: throw (new ArgumentException(offsetCreationXmlType.ToString())); } sb.AppendFormat ( TABLE_ROW_FORMAT, (++number), tuple.Subject.ToHtml(), tuple.Object.ToHtml(), html //tuple.Sentence.MakeFinalTonalityXslt( server ) ); } sb.Append(TABLE_END); return(sb.ToString()); }
public static string ToHtmlTableAndXmlCustomBySent <T> ( this OutputResultTupleBase <T> result, OutputTypeEnum outputType, HttpServerUtility server, OffsetsProcessor offsetsProcessor, string originalText, OffsetCreationXmlTypeEnum offsetCreationXmlType ) where T : OpinionMiningTuple { if (!result.Tuples.Any()) { return(ANYTHING_ISNT_PRESENT); } var sbGlobal = new StringBuilder(); var number = 0; foreach (var tuple in result.Tuples) { var offsetsString = offsetsProcessor.CreateOffsetsString(tuple.GetSentence()); //var offsetsXml = offsetsProcessor.CreateOffsetsString( tuple.GetSentence(), global::OffsetsBases.TextFormat.Xml ); var xdoc = default(XDocument); var html = default(string); switch (offsetCreationXmlType) { case OffsetCreationXmlTypeEnum.Flat: xdoc = OffsetsString2XDocumentConverter.ConvertToFlat(originalText, offsetsString); html = xdoc.MakeOffsetsFlatXslt(server); break; case OffsetCreationXmlTypeEnum.Hierarchy: xdoc = OffsetsString2XDocumentConverter.ConvertToHierarchy(originalText, offsetsString); html = xdoc.MakeOffsetsHierarchyXslt(server); break; default: throw (new ArgumentException(offsetCreationXmlType.ToString())); } //1. var sb = new StringBuilder(TABLE_START); sb.AppendFormat ( TABLE_ROW_FORMAT, (++number), tuple.Subject.ToHtml(), tuple.Object.ToHtml(), html //tuple.Sentence.MakeFinalTonalityXslt(server) ); sb.Append(TABLE_END); //2. sb.Append(xdoc.ToString().MakeXslt(outputType, server)); //sb.Append( tuple.Sentence.ToString().MakeXslt( outputType, server ) ); //3. sbGlobal.Append(sb.ToString()); } return(sbGlobal.ToString()); }