<commit_before>public struct WikidataAPIResult: Decodable {
    public struct APIError: Error, Decodable {
        public let code, info: String?
    }
    let error: APIError?
    let success: Int?
}

struct MediaWikiSiteInfoResult: Decodable {
    struct MediaWikiQueryResult: Decodable {
        struct MediaWikiGeneralResult: Decodable {
            let lang: String
        }
        let general: MediaWikiGeneralResult
    }
    let query: MediaWikiQueryResult
}

extension WikidataAPIResult {
    var succeeded: Bool {
        return success == 1
    }
}

enum WikidataPublishingError: LocalizedError {
    case invalidArticleURL
    case apiResultNotParsedCorrectly
    case notEditable
    case unknown
}

@objc public final class WikidataDescriptionEditingController: Fetcher {
    static let DidMakeAuthorizedWikidataDescriptionEditNotification = NSNotification.Name(rawValue: "WMFDidMakeAuthorizedWikidataDescriptionEdit")
    /// Publish new wikidata description.
    ///
    /// - Parameters:
    ///   - newWikidataDescription: new wikidata description to be published, e.g., "Capital of England and the United Kingdom".
    ///   - source: description source; none, central or local.
    ///   - wikidataID: id for the Wikidata entity including the prefix
    ///   - language: language code of the page's wiki, e.g., "en".
    ///   - completion: completion block called when operation is completed.
    public func publish(newWikidataDescription: String, from source: ArticleDescriptionSource, forWikidataID wikidataID: String, language: String, completion: @escaping (Error?) -> Void) {
        guard source != .local else {
            completion(WikidataPublishingError.notEditable)
            return
        }
        let requestWithCSRFCompletion: (WikidataAPIResult?, URLResponse?, Bool?, Error?) -> Void = { result, response, authorized, error in
            if let error = error {
                completion(error)
            }
            guard let result = result else {
                completion(WikidataPublishingError.apiResultNotParsedCorrectly)
                return
            }

            completion(result.error)

            if let authorized = authorized, authorized, result.error == nil {
                DispatchQueue.main.async {
                    NotificationCenter.default.post(name: WikidataDescriptionEditingController.DidMakeAuthorizedWikidataDescriptionEditNotification, object: nil)<commit_msg>notify when wikidata description edit is published<commit_after>public struct WikidataAPIResult: Decodable {
    public struct APIError: Error, Decodable {
        public let code, info: String?
    }
    let error: APIError?
    let success: Int?
}

struct MediaWikiSiteInfoResult: Decodable {
    struct MediaWikiQueryResult: Decodable {
        struct MediaWikiGeneralResult: Decodable {
            let lang: String
        }
        let general: MediaWikiGeneralResult
    }
    let query: MediaWikiQueryResult
}

extension WikidataAPIResult {
    var succeeded: Bool {
        return success == 1
    }
}

enum WikidataPublishingError: LocalizedError {
    case invalidArticleURL
    case apiResultNotParsedCorrectly
    case notEditable
    case unknown
}

@objc public final class WikidataDescriptionEditingController: Fetcher {
    @objc static let didPublishNotification = NSNotification.Name(rawValue: "WikidataDescriptionEditingControllerDidPublishNotification")
    /// Publish new wikidata description.
    ///
    /// - Parameters:
    ///   - newWikidataDescription: new wikidata description to be published, e.g., "Capital of England and the United Kingdom".
    ///   - source: description source; none, central or local.
    ///   - wikidataID: id for the Wikidata entity including the prefix
    ///   - language: language code of the page's wiki, e.g., "en".
    ///   - completion: completion block called when operation is completed.
    public func publish(newWikidataDescription: String, from source: ArticleDescriptionSource, forWikidataID wikidataID: String, language: String, completion: @escaping (Error?) -> Void) {
        guard source != .local else {
            completion(WikidataPublishingError.notEditable)
            return
        }
        let requestWithCSRFCompletion: (WikidataAPIResult?, URLResponse?, Bool?, Error?) -> Void = { result, response, authorized, error in
            if let error = error {
                completion(error)
            }
            guard let result = result else {
                completion(WikidataPublishingError.apiResultNotParsedCorrectly)
                return
            }

            completion(result.error)

            if let authorized = authorized, authorized, result.error == nil {
                DispatchQueue.main.async {
                    NotificationCenter.default.post(name: WikidataDescriptionEditingController.didPublishNotification, object: authorized)
{'fraction_non_alphanumeric': 0.07356837171387813, 'fraction_numerical': 0.0004075810067250866, 'mean_word_length': 2.7753846153846156, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3136424', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1265, 'n_words': 366}