<commit_before>//
//  RegionKindStreamCellTypeAddition.swift
//  Ello
//
//  Created by Sean on 2/9/16.
//  Copyright © 2016 Ello. All rights reserved.
//

import Foundation

extension RegionKind {
    public func streamCellTypes(regionable: Regionable) -> [StreamCellType] {
        switch self {
        case .Image:
            return [.Image(data: regionable)]
        case .Text:
            return [.Text(data: regionable)]
        case .Embed:
            return [.Embed(data: regionable)]
        case .Unknown:
            return [.Unknown]
        }
    }
}<commit_msg>split up text regions by paragraph<commit_after>//
//  RegionKindStreamCellTypeAddition.swift
//  Ello
//
//  Created by Sean on 2/9/16.
//  Copyright © 2016 Ello. All rights reserved.
//

import Foundation

extension RegionKind {
    public func streamCellTypes(regionable: Regionable) -> [StreamCellType] {
        switch self {
        case .Image:
            return [.Image(data: regionable)]
        case .Text:
            if let textRegion = regionable as? TextRegion {
                let content = textRegion.content
                let paragraphs = content.componentsSeparatedByString("</p>")
                return paragraphs.flatMap { (para: String) -> StreamCellType? in
                    if para == "" {
                        return nil
                    }

                    let newRegion = TextRegion(content: para + "</p>")
                    newRegion.isRepost = textRegion.isRepost
                    return .Text(data: newRegion)
                }
            }
            return []
        case .Embed:
            return [.Embed(data: regionable)]
        case .Unknown:
            return [.Unknown]
        }
    }
}
{'fraction_non_alphanumeric': 0.10109763142692085, 'fraction_numerical': 0.00924321201617562, 'mean_word_length': 1.6045112781954887, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '6612540', 'n_tokens_mistral': 484, 'n_tokens_neox': 450, 'n_words': 125}