<commit_before>import Argo
import Curry
import Runes

public struct Path: ResourceType {
  
  public let type: String
  public let id: String
  public let attributes: Attributes
  public let links: Links
  
  public struct Attributes {
    public let fileVersion: String
    public let position: Double
    public let chapter: Int
    public let cfi: String
    public let title: String?
    public let preContent: String?
    public let content: String
    public let postContent: String?
    public let referencedCount: Int
  }

  public struct Links {
    public let selfLink: String
  }
  
}

// MARK: - Decodable
extension Path: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<Path> {
    return curry(Path.init)
      <^> json <| "type"
      <*> json <| "id"
      <*> json <| "attributes"
      <*> json <| "links"
  }
}

extension Path.Attributes: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<Path.Attributes> {
    let tmp1 = curry(Path.Attributes.init)
      <^> json <| "file_version"
      <*> json <| "position"
      <*> json <| "chapter"
      <*> json <| "cfi"
    
    let tmp2 = tmp1
      <*> json <|? "title"
      <*> json <|? "pre_content"
      <*> json <| "content"
    
    return tmp2 
      <*> json <|? "post_content"
      <*> json <| "referenced_count"
  }
}

extension Path.Links: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<Path.Links> {
    return curry(Path.Links.init)
      <^> json <| "self"
  }<commit_msg>[Feature] Path 增加 loc 屬性<commit_after>import Argo
import Curry
import Runes

public struct Path: ResourceType {
  
  public let type: String
  public let id: String
  public let attributes: Attributes
  public let links: Links
  
  public struct Attributes {
    public let fileVersion: String
    public let position: Double
    public let chapter: Int
    public let cfi: String
    public let loc: Int?
    public let title: String?
    public let preContent: String?
    public let content: String
    public let postContent: String?
    public let referencedCount: Int
  }

  public struct Links {
    public let selfLink: String
  }
  
}

// MARK: - Decodable
extension Path: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<Path> {
    return curry(Path.init)
      <^> json <| "type"
      <*> json <| "id"
      <*> json <| "attributes"
      <*> json <| "links"
  }
}

extension Path.Attributes: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<Path.Attributes> {
    let tmp1 = curry(Path.Attributes.init)
      <^> json <| "file_version"
      <*> json <| "position"
      <*> json <| "chapter"
      <*> json <| "cfi"
      <*> json <|? "loc"
    
    let tmp2 = tmp1
      <*> json <|? "title"
      <*> json <|? "pre_content"
      <*> json <| "content"
    
    return tmp2 
      <*> json <|? "post_content"
      <*> json <| "referenced_count"
  }
}

extension Path.Links: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<Path.Links> {
    return curry(Path.Links.init)
      <^> json <| "self"
  }
{'fraction_non_alphanumeric': 0.12463674523732644, 'fraction_numerical': 0.002583144979011947, 'mean_word_length': 2.67497034400949, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 44, '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': '7523137', 'n_tokens_mistral': 1030, 'n_tokens_neox': 1005, 'n_words': 298}