<commit_before>﻿using System.Xml.Linq;
using Skybrud.Essentials.Locations;
using Skybrud.Essentials.Xml.Extensions;
using Skybrud.Social.Flickr.Enums;

namespace Skybrud.Social.Flickr.Objects.Places {
    
    /// <summary>
    /// Class representing a place.
    /// </summary>
    public class FlickrPlaceItem : FlickrObject, ILocation {

        #region Properties

        /// <summary>
        /// Gets the ID of the place.
        /// </summary>
        public string Id { get; private set; }

        /// <summary>
        /// Gets Where On Earth (WOE) ID of the place.
        /// </summary>
        public string WoeId { get; private set; }

        /// <summary>
        /// Gets the latitude of the place.
        /// </summary>
        public double Latitude { get; private set; }

        /// <summary>
        /// Gets the longitude of the place.
        /// </summary>
        public double Longitude { get; private set; }

        /// <summary>
        /// Gets the Flickr URL of the place.
        /// </summary>
        public string PlaceUrl { get; private set; }

        /// <summary>
        /// Gets the type of the place.
        /// </summary>
        public FlickrPlaceType PlaceType { get; private set; }

        /// <summary>
        /// Gets the ID of the type of the place.
        /// </summary>
        public int PlaceTypeId { get; private set; }

        /// <summary>
        /// Gets the name of the timezone of the place - eg. <code>Europe/London</code> or
        /// <code>Europe/Copenhagen</code>.
        /// </summary>
        public string Timezone { get; private set; }

        /// <summary>
        /// Gets Where On Earth (WOE) name of the place.
        /// </summary>
        public string WoeName { get; private set; }

        /// <summary>
        /// Gets the name of the place.
        /// </summary>
        public string Name { get; private set; }

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance from the specified <paramref name="xml"/>.
        /// </summary>
        /// <param name="xml">The instance of <see cref="XElement"/> representing the object.</param>
        protected FlickrPlaceItem(XElement xml) : base(xml) {

            // Parse the attributes
            Id = xml.GetAttributeValue("place_id");
            WoeId = xml.GetAttributeValue("woeid");
            Latitude = xml.GetAttributeValue<double>("latitude");
            Longitude = xml.GetAttributeValue<double>("longitude");
            PlaceUrl = xml.GetAttributeValue("place_url");
            PlaceType = xml.GetAttributeValueAsEnum<FlickrPlaceType>("place_type");
            PlaceTypeId = xml.GetAttributeValue<int>("place_type_id");
            Timezone = xml.GetAttributeValue("timezone");
            WoeName = xml.GetAttributeValue("woe_name");
            
            // Get the name from the inner text
            Name = xml.Value;
        
        }

        #endregion<commit_msg>Fixed the parsing a bit<commit_after>﻿using System;
using System.Xml.Linq;
using Skybrud.Essentials.Locations;
using Skybrud.Essentials.Xml.Extensions;
using Skybrud.Social.Flickr.Enums;

namespace Skybrud.Social.Flickr.Objects.Places {
    
    /// <summary>
    /// Class representing a place.
    /// </summary>
    public class FlickrPlaceItem : FlickrObject, ILocation {

        #region Properties

        /// <summary>
        /// Gets the ID of the place.
        /// </summary>
        public string Id { get; private set; }

        /// <summary>
        /// Gets Where On Earth (WOE) ID of the place.
        /// </summary>
        public string WoeId { get; private set; }

        /// <summary>
        /// Gets the latitude of the place.
        /// </summary>
        public double Latitude { get; private set; }

        /// <summary>
        /// Gets the longitude of the place.
        /// </summary>
        public double Longitude { get; private set; }

        /// <summary>
        /// Gets the Flickr URL of the place.
        /// </summary>
        public string PlaceUrl { get; private set; }

        /// <summary>
        /// Gets the type of the place.
        /// </summary>
        public FlickrPlaceType PlaceType { get; private set; }

        /// <summary>
        /// Gets the ID of the type of the place.
        /// </summary>
        public int PlaceTypeId { get; private set; }

        /// <summary>
        /// Gets the name of the timezone of the place - eg. <code>Europe/London</code> or
        /// <code>Europe/Copenhagen</code>.
        /// </summary>
        public string Timezone { get; private set; }

        /// <summary>
        /// Gets Where On Earth (WOE) name of the place.
        /// </summary>
        public string WoeName { get; private set; }

        /// <summary>
        /// Gets the name of the place.
        /// </summary>
        public string Name { get; private set; }

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance from the specified <paramref name="xml"/>.
        /// </summary>
        /// <param name="xml">The instance of <see cref="XElement"/> representing the object.</param>
        protected FlickrPlaceItem(XElement xml) : base(xml) {

            double latitude;
            double longitude;
            int placeTypeId;
            
            // Parse the attributes
            Id = xml.GetAttributeValue("place_id");
            WoeId = xml.GetAttributeValue("woeid");
            Latitude = xml.GetAttributeValueAsDouble("latitude", out latitude) ? latitude : 0;
            Longitude = xml.GetAttributeValueAsDouble("longitude", out longitude) ? longitude : 0;
            PlaceUrl = xml.GetAttributeValue("place_url");
            PlaceType = xml.GetAttributeValueAsEnum("place_type", FlickrPlaceType.Unknown);
            PlaceTypeId = xml.GetAttributeValueAsInt32("place_type_id", out placeTypeId) ? placeTypeId : 0;
            Timezone = xml.GetAttributeValue("timezone");
            WoeName = xml.GetAttributeValue("woe_name");

            // Get the name from the inner text
            Name = xml.Value;

            if (String.IsNullOrWhiteSpace(Name)) {
                Name = xml.GetAttributeValue("name");
            }
        
        }

        #endregion
{'fraction_non_alphanumeric': 0.12357594936708861, 'fraction_numerical': 0.0007911392405063291, 'mean_word_length': 1.7198795180722892, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 29}, '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': '6718329', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1664, 'n_words': 504}