public void ParseWebTextTest(string text) { var regex = new Regex(NiconicoWebTextPatterns.niconicoWebTextParsePattern); var segmenter = new NiconicoWebTextSegmenter(); var match = regex.Match(text); Assert.IsTrue(match.Success); IReadOnlyNiconicoWebTextSegment segment = HtmlBreakNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>.ParseWebText(match, segmenter, null); Assert.AreEqual(NiconicoWebTextSegmentType.LineBreak, segment.SegmentType); }
public void SegmentationTestInitialize() { this.resultTable_ = new Dictionary<string, IReadOnlyList<IReadOnlyNiconicoWebTextSegment>>(); this.resultTable_.Add("plain1",creaeteTestCase( new PlainNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>("plainText",null))); this.resultTable_.Add("url1", creaeteTestCase(new PlainNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>("plain",null), new UrlNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>(new Uri("http://www.nicovideo.jp/watch/sm21305680"),null), new PlainNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>(" oooo",null)) ); this.resultTable_.Add("various1", creaeteTestCase(new PlainNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>("plain",null), createSegmentsContainerCase( new HtmlBoldNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>(null), new PlainNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>("plain2", null), createSegmentsContainerCase(new HtmlUnderLineNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>(null), new PlainNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>("underline", null) ) ), new HtmlBreakNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>(null), new PlainNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>("test",null) ) ); this.resultTable_.Add("variousId", creaeteTestCase ( createSegmentsContainerCase(new HtmlInvalidElementNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>(null),new PlainNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>("invalid",null)), new VideoIdNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>("sm22811971",null) ) ); this.resultTable_.Add ("font1", creaeteTestCase ( createSegmentsContainerCase(new HtmlFontNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>(4, new NiconicoTextColor { R = 0xFF, G = 0x00, B = 0x00 }, null), new PlainNiconicoWebTextSegment<IReadOnlyNiconicoWebTextSegment>("text",null) ) ) ); this.resultTable_.Add("font2",this.resultTable_["font1"]); this.segmenter_ = new NiconicoWebTextSegmenter(); }
internal static INiconicoWebTextSegment ParseWatchPictureIdWebText(Match match, NiconicoWebTextSegmenter segmenter, INiconicoWebTextSegment parent) { return WatchPictureIdNiconicoWebTextSegment<INiconicoWebTextSegment>.ParseWebText(match, segmenter, parent); }
private static void setSegments(WriteableNiconicoWebTextSegment segment,NiconicoWebTextSegmenter segmenter) { segment.Segments = new NiconicoWebTextSegmentCollection(segment, segmenter.WritablePartialDivide(segment.FriendlyText, segment)); }
internal static INiconicoWebTextSegment ParseNumberAnchorWebText(Match match, NiconicoWebTextSegmenter segmenter, INiconicoWebTextSegment parent) { return NumberAnchorNiconicoWebTextSegment<INiconicoWebTextSegment>.ParseWebText(match, segmenter, parent); }
internal static INiconicoWebTextSegment ParseUrlWebText(Match match, NiconicoWebTextSegmenter segmenter, INiconicoWebTextSegment parent) { return UrlNiconicoWebTextSegment<INiconicoWebTextSegment>.ParseWebText(match, segmenter, parent); }
internal static INiconicoWebTextSegment ParseLineBreakWebText(Match match, NiconicoWebTextSegmenter segmenter, INiconicoWebTextSegment parent) { return new WriteableNiconicoWebTextSegment(match.Value, Environment.NewLine, NiconicoWebTextSegmentType.LineBreak, NiconicoWebTextDecorateFlags.None, parent, null); }
internal static INiconicoWebTextSegment ParseMarketItemIdWebText(Match match, NiconicoWebTextSegmenter segmenter, INiconicoWebTextSegment parent) { return MarketItemIdNiconicoWebTextSegment<INiconicoWebTextSegment>.ParseWebText(match, segmenter, parent); }
internal static INiconicoWebTextSegment ParseHtmlUnderLineWebText(Match match, NiconicoWebTextSegmenter segmenter, INiconicoWebTextSegment parent) { var segment = new WriteableNiconicoWebTextSegment(match.Value, match.Groups[NiconicoWebTextPatternIndexs.underLineTextGroupNumber].Value, NiconicoWebTextSegmentType.HtmlUnderLineElement, NiconicoWebTextDecorateFlags.DecoratedUnderLineFlag, parent, null); setSegments(segment, segmenter); return segment; }
internal static INiconicoWebTextSegment ParseHtmlInvalidElementWebText(Match match, NiconicoWebTextSegmenter segmenter, INiconicoWebTextSegment parent) { var segment = new WriteableNiconicoWebTextSegment(match.Value, string.Empty, NiconicoWebTextSegmentType.HtmlInvalidElement, NiconicoWebTextDecorateFlags.None, parent, null); segment.Segments = new NiconicoWebTextSegmentCollection(segment, segmenter.WritablePartialDivide(segment.Text.Substring(1, segment.Text.Length - 1), segment)); return segment; }
internal static WriteableNiconicoWebTextSegment ParseHtmlFontWebText(Match match, NiconicoWebTextSegmenter segmenter, INiconicoWebTextSegment parent) { var segment = new WriteableNiconicoWebTextSegment(match.Value,match.Groups[NiconicoWebTextPatternIndexs.fontTextGroupNumber].Value, NiconicoWebTextSegmentType.HtmlFontElement,NiconicoWebTextDecorateFlags.None, parent,null); var readOnlySegment = HtmlFontNiconicoWebTextSegment<INiconicoWebTextSegment>.ParseWebTextPartial(match, parent); segment.FontElementSize = readOnlySegment.FontElementSize; setSegments(segment, segmenter); if (readOnlySegment.DecoratedColor) { segment.Color = readOnlySegment.Color; segment.decorateFlag_ |= NiconicoWebTextDecorateFlags.DecoratedColorFlag; } return segment; }
internal static INiconicoWebTextSegment ParseHtmlBreakWebText(Match match, NiconicoWebTextSegmenter segmenter, INiconicoWebTextSegment parent) { return ParseLineBreakWebText(match, segmenter, parent); }
internal static INiconicoWebTextSegment ParseCommunityIdWebText(Match match, NiconicoWebTextSegmenter segmenter, INiconicoWebTextSegment parent) { return CommunityIdNiconicoWebTextSegment<INiconicoWebTextSegment>.ParseWebText(match, segmenter, parent); }