<commit_before>﻿using Sdl.Web.Common.Models;
using System;
using System.Collections.Generic;
using System.ServiceModel.Syndication;
using Sdl.Web.Common.Configuration;

namespace Sdl.Web.Modules.Core.Models
{
    [SemanticEntity(EntityName = "Teaser", Prefix = "t", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "Image", Prefix = "i", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "Article", Prefix = "a", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "NewsArticle", Prefix = "na", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "Place", Prefix = "p", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "StandardMetadata", Prefix = "m", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "LinkedContent", Prefix = "c", Vocab = CoreVocabulary)]
    [Serializable]
    public class Teaser : EntityModel, ISyndicationFeedItemProvider
    {
        //A teaser can be mapped from an article or place, in which case the link should be to the item itself
        [SemanticProperty("na:_self")]
        [SemanticProperty("a:_self")]
        [SemanticProperty("p:_self")]
        [SemanticProperty("c:link")]

        public Link Link { get; set; }
        
        [SemanticProperty("na:name")]
        [SemanticProperty("a:name")]
        [SemanticProperty("headline")]
        [SemanticProperty("t:headline")]
        [SemanticProperty("a:headline")]
        [SemanticProperty("subheading")]
        [SemanticProperty("p:name")]
        [SemanticProperty("c:subheading")]
        public string Headline { get; set; }
        
        //A teaser can be mapped from an individual image, in which case the image property is set from the source entity itself
        [SemanticProperty("i:_self")]
        [SemanticProperty("a:image")]
        [SemanticProperty("na:image")]
        [SemanticProperty("c:media")]
        public MediaItem Media { get; set; }

        [SemanticProperty("na:introText")]
        [SemanticProperty("a:introText")]
        [SemanticProperty("content")]
        [SemanticProperty("description")]
        [SemanticProperty("m:description")]
        [SemanticProperty("c:content")]
        public RichText Text { get; set; }

        [SemanticProperty("dateCreated")]
        public DateTime? Date { get; set; }

        public Location Location { get; set; }

        //To store formatting options for the teaser (link style etc.)
        [SemanticProperty(IgnoreMapping=true)]
        private Dictionary<string, string> FormatOptions { get; set; }

        public string GetFormatOption(string key, string defaultValue = null)
        {
            if (FormatOptions != null && FormatOptions.ContainsKey(key))
            {
                return FormatOptions[key];
            }

            return defaultValue;
        }

        public void SetFormatOption(string key, string value)
        {
            if (FormatOptions == null)
            {
                FormatOptions = new Dictionary<string, string>();<commit_msg>TSI-2275 : fixed missing date<commit_after>﻿using Sdl.Web.Common.Models;
using System;
using System.Collections.Generic;
using System.ServiceModel.Syndication;
using Sdl.Web.Common.Configuration;

namespace Sdl.Web.Modules.Core.Models
{
    [SemanticEntity(EntityName = "Teaser", Prefix = "t", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "Image", Prefix = "i", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "Article", Prefix = "a", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "NewsArticle", Prefix = "na", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "Place", Prefix = "p", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "StandardMetadata", Prefix = "m", Vocab = CoreVocabulary)]
    [SemanticEntity(EntityName = "LinkedContent", Prefix = "c", Vocab = CoreVocabulary)]
    [Serializable]
    public class Teaser : EntityModel, ISyndicationFeedItemProvider
    {
        //A teaser can be mapped from an article or place, in which case the link should be to the item itself
        [SemanticProperty("na:_self")]
        [SemanticProperty("a:_self")]
        [SemanticProperty("p:_self")]
        [SemanticProperty("c:link")]

        public Link Link { get; set; }
        
        [SemanticProperty("na:name")]
        [SemanticProperty("a:name")]
        [SemanticProperty("headline")]
        [SemanticProperty("t:headline")]
        [SemanticProperty("a:headline")]
        [SemanticProperty("subheading")]
        [SemanticProperty("p:name")]
        [SemanticProperty("c:subheading")]
        public string Headline { get; set; }
        
        //A teaser can be mapped from an individual image, in which case the image property is set from the source entity itself
        [SemanticProperty("i:_self")]
        [SemanticProperty("a:image")]
        [SemanticProperty("na:image")]
        [SemanticProperty("c:media")]
        public MediaItem Media { get; set; }

        [SemanticProperty("na:introText")]
        [SemanticProperty("a:introText")]
        [SemanticProperty("content")]
        [SemanticProperty("description")]
        [SemanticProperty("m:description")]
        [SemanticProperty("c:content")]
        public RichText Text { get; set; }

        [SemanticProperty("dateCreated")]
        [SemanticProperty("m:dateCreated")]
        [SemanticProperty("c:date")]
        public DateTime? Date { get; set; }

        public Location Location { get; set; }

        //To store formatting options for the teaser (link style etc.)
        [SemanticProperty(IgnoreMapping=true)]
        private Dictionary<string, string> FormatOptions { get; set; }

        public string GetFormatOption(string key, string defaultValue = null)
        {
            if (FormatOptions != null && FormatOptions.ContainsKey(key))
            {
                return FormatOptions[key];
            }

            return defaultValue;
        }

        public void SetFormatOption(string key, string value)
        {
            if (FormatOptions == null)
            {
                FormatOptions = new Dictionary<string, string>();
{'fraction_non_alphanumeric': 0.12080536912751678, 'fraction_numerical': 0.0006547716483876248, 'mean_word_length': 2.9882506527415145, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1069575', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1669, 'n_words': 406}