<commit_before>//
//  AtomOpenSearchEngineExtension.cs
//
//  Author:
//       <NAME> <<EMAIL>>
//
//  Copyright (c) 2014 Terradue

using System;
using System.Linq;
using Mono.Addins;
using System.ServiceModel.Syndication;
using System.Collections.Generic;
using System.Xml;
using System.Net;
using System.Diagnostics;
using System.Collections.Specialized;
using Terradue.OpenSearch.Response;
using Terradue.OpenSearch.Result;
using Terradue.OpenSearch.Schema;

namespace Terradue.OpenSearch.Engine.Extensions {
    /// <summary>
    /// Atom open search engine extension.
    /// </summary>
    [Extension(typeof(IOpenSearchEngineExtension))]
    [ExtensionNode("Atom", "Atom native query")]
    public class AtomOpenSearchEngineExtension : OpenSearchEngineExtension<SyndicationFeed> {
        public AtomOpenSearchEngineExtension() {
        }

        #region implemented abstract members of OpenSearchEngineExtension

        public override string Identifier {
            get {
                return "Atom";
            }
        }

        public override string Name {
            get {
                return "ATOM Syndication Feed";
            }
        }

        public override string[] GetInputFormatTransformPath() {
            return new string[] { "application/atom+xml", "application/xml" };
        }

        public override object TransformResponse(OpenSearchResponse response) {
            if (response.ContentType == "application/atom+xml") return TransformAtomResponseToSyndicationFeed(response);
            if (response.ContentType == "application/xml") return TransformAtomResponseToSyndicationFeed(response);

            throw new InvalidOperationException("Atom extension does not transform OpenSearch response from " + response.ContentType);
        }

        public override string DiscoveryContentType {
            get {
                return "application/atom+xml";
            }
        }

        public override OpenSearchUrl FindOpenSearchDescriptionUrlFromResponse(OpenSearchResponse response) {
            SyndicationFeed feed = TransformAtomResponseToSyndicationFeed(response);
            SyndicationLink link = feed.Links.FirstOrDefault(l => l.RelationshipType == "search" && l.MediaType.Contains("opensearch"));
            if (link == null) return null;
            return new OpenSearchUrl(link.Uri);
        }

        public override SyndicationLink[] GetEnclosures(IOpenSearchResult results) {

            List<SyndicationLink> links = new List<SyndicationLink>();

            foreach (SyndicationItem item in ((SyndicationFeed)results).Items) {
                foreach (SyndicationLink link in item.Links) {<commit_msg>typocorrection<commit_after>//
//  AtomOpenSearchEngineExtension.cs
//
//  Author:
//       <NAME> <<EMAIL>>
//
//  Copyright (c) 2014 Terradue

using System;
using System.Linq;
using Mono.Addins;
using System.ServiceModel.Syndication;
using System.Collections.Generic;
using System.Xml;
using System.Net;
using System.Diagnostics;
using System.Collections.Specialized;
using Terradue.OpenSearch.Response;
using Terradue.OpenSearch.Result;
using Terradue.OpenSearch.Schema;

namespace Terradue.OpenSearch.Engine.Extensions {
    /// <summary>
    /// Atom open search engine extension.
    /// </summary>
    [Extension(typeof(IOpenSearchEngineExtension))]
    [ExtensionNode("Atom", "Atom native query")]
    public class AtomOpenSearchEngineExtension : OpenSearchEngineExtension<SyndicationFeed> {
        public AtomOpenSearchEngineExtension() {
        }

        #region implemented abstract members of OpenSearchEngineExtension

        public override string Identifier {
            get {
                return "Atom";
            }
        }

        public override string Name {
            get {
                return "ATOM Syndication Feed";
            }
        }

        public override string[] GetInputFormatTransformPath() {
            return new string[] { "application/atom+xml", "application/xml" };
        }

        public override object TransformResponse(OpenSearchResponse response) {
            if (response.ContentType == "application/atom+xml") return TransformAtomResponseToSyndicationFeed(response);
            if (response.ContentType == "application/xml") return TransformAtomResponseToSyndicationFeed(response);

            throw new InvalidOperationException("Atom extension does not transform OpenSearch response from " + response.ContentType);
        }

        public override string DiscoveryContentType {
            get {
                return "application/atom+xml";
            }
        }

        public override OpenSearchUrl FindOpenSearchDescriptionUrlFromResponse(OpenSearchResponse response) {
            SyndicationFeed feed = TransformAtomResponseToSyndicationFeed(response);
            SyndicationLink link = feed.Links.FirstOrDefault(l => l.RelationshipType == "search" && l.MediaType.Contains("opensearch"));
            if (link == null) return null;
            return new OpenSearchUrl(link.Uri);
        }

        public override SyndicationLink[] GetEnclosures(IOpenSearchResult results) {

            List<SyndicationLink> links = new List<SyndicationLink>();

            foreach (SyndicationItem item in ((SyndicationFeed)results.Result).Items) {
                foreach (SyndicationLink link in item.Links) {
{'fraction_non_alphanumeric': 0.08889303019008572, 'fraction_numerical': 0.0014908684308609765, 'mean_word_length': 2.8445558739255015, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '4268652', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1321, 'n_words': 316}