# Bug in card splitting logic

**URL:** <https://forum.kinopio.club/t/bug-in-card-splitting-logic/372>\
**Category:** Fixed or Completed\
**Created:** [July 8, 2021, 1:22pm UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372 "2021-07-08T13:22:17Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![bentsai](https://forum.kinopio.club/user_avatar/forum.kinopio.club/bentsai/32/8_2.png) [@bentsai](https://forum.kinopio.club/u/bentsai)\
**Post date:** [July 8, 2021, 1:22pm UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/1 "2021-07-08T13:22:17Z")

</div>

Continuing the discussion from [Bugs in card splitting logic](https://forum.kinopio.club/t/bugs-in-card-splitting-logic/359/11):

I found a bug where this is not working as desired. It seems like the case where this happens is when you paste more than 300 characters and have 2 or more line breaks. This is a very common case, for example, when you want to have a list of items split into that many number of cards:

```auto
:watermelon:Watermelon Ham, The Non-Linear Toolbox, and Your Desktop Pal - The Land of Random (substack.com) 1
https://stegriff.co.uk/upblog/web-pages-with-personality/ 1 and https://stegriff.co.uk/upblog/baby-griff/
https://tiv.today/2021/06/kinopio 2
https://design.futureland.tv/vin/futureland-design/82632?fullscreen=1

```

Or also:

- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
- Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

The current logic seems to always try to split it into only 2 cards.

---

<div class="post-metadata">

**Author:** ![pirijan](https://forum.kinopio.club/user_avatar/forum.kinopio.club/pirijan/32/7_2.png) [@pirijan](https://forum.kinopio.club/u/pirijan)\
**Post date:** [August 2, 2021, 3:18pm UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/2 "2021-08-02T15:18:58Z")

</div>

working on this now

---

<div class="post-metadata">

**Author:** ![pirijan](https://forum.kinopio.club/user_avatar/forum.kinopio.club/pirijan/32/7_2.png) [@pirijan](https://forum.kinopio.club/u/pirijan)\
**Post date:** [August 2, 2021, 3:29pm UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/3 "2021-08-02T15:29:49Z")

</div>

multi-paragraph should be fixed now

 ![Screen Shot 2021-08-02 at 11.28.28 AM](https://forum.kinopio.club/uploads/default/original/1X/f88c312afdb61246fb5e15a818b2d94ac4fda949.png)

let me know if you find any other issues

---

<div class="post-metadata">

**Author:** ![bentsai](https://forum.kinopio.club/user_avatar/forum.kinopio.club/bentsai/32/8_2.png) [@bentsai](https://forum.kinopio.club/u/bentsai)\
**Post date:** [August 3, 2021, 2:43pm UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/4 "2021-08-03T14:43:23Z")

</div>

Here is a test case which I consider a bug:

```auto
1 In the beginning God created the heavens and the earth. 2 Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters.

3 And God said, “Let there be light,” and there was light. 4 God saw that the light was good, and he separated the light from the darkness. 5 God called the light “day,” and the darkness he called “night.” And there was evening, and there was morning—the first day.

```

This is two paragraphs. Both paragraphs individually fit into a single card. So I think the algorithm should prioritize keeping paragraphs together if possible. However, the algorithm splits this into 5 sentences, which is OK, but loses the paragraph information.

 ![image](https://forum.kinopio.club/uploads/default/original/1X/c32e2287ed943547b9f2653c2927aabc60583ec5.png)

---

<div class="post-metadata">

**Author:** ![pirijan](https://forum.kinopio.club/user_avatar/forum.kinopio.club/pirijan/32/7_2.png) [@pirijan](https://forum.kinopio.club/u/pirijan)\
**Post date:** [August 3, 2021, 3:18pm UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/5 "2021-08-03T15:18:05Z")

</div>

i would consider it a different interpretation, rather than a bug. Doing the ‘right’/smart thing here, may mean doing the ‘wrong’ thing in another case so I learn towards predictability in all cases

as a non-subject-matter expert, having 1, 2, 3, etc. as separate cards in this case seems a lot more readable though?

---

<div class="post-metadata">

**Author:** ![bentsai](https://forum.kinopio.club/user_avatar/forum.kinopio.club/bentsai/32/8_2.png) [@bentsai](https://forum.kinopio.club/u/bentsai)\
**Post date:** [August 3, 2021, 3:31pm UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/6 "2021-08-03T15:31:46Z")

</div>

> [@pirijan](#):
>
> Doing the ‘right’/smart thing here, may mean doing the ‘wrong’ thing in another case so I learn towards predictability in all cases

What would be a case where the proposed algorithm would do the “wrong” thing?

> [@pirijan](#):
>
> as a non-subject-matter expert, having 1, 2, 3, etc. as separate cards in this case seems a lot more readable though?

Readability is important, but I think retaining information is more important. This is not specific to bible passages, but for any kind of writing: I have two paragraphs, and when I paste those into Kinopio, I want my paragraphs to be preserved because I treat those as units of information. The current algorithm throws that information away.

What I think is predictable is, “Keep paragraphs together as much as possible. If a paragraph is longer than 300 characters, start taking off sentences from the end until it fits.” Admittedly there are edge cases here which are ambiguous and we can talk about.

Also, what would make the current algorithm more palatable would be a way to _combine_ cards, making it easier to put paragraphs back together. So, paint some cards, and if they all fit on one card, add a button to combine/join them together.

But I still think doing the smart/right thing is preferable 🙂 What is your idea of the “right” thing?

---

<div class="post-metadata">

**Author:** ![kordumb](https://forum.kinopio.club/user_avatar/forum.kinopio.club/kordumb/32/1832_2.png) [@kordumb](https://forum.kinopio.club/u/kordumb)\
**Post date:** [August 3, 2021, 9:07pm UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/7 "2021-08-03T21:07:35Z")

</div>

So when I brought in a numbered list, I was hoping it would treat it like the “Observed” above. But since my numbered list was formatted as:

1. First item
2. Second item
3. Third item

It actually split into six cards “1.”, “First item”, “2.”, etc.

Knowing I can remove the periods and it would split it into three cards is nice to know…

---

<div class="post-metadata">

**Author:** ![bentsai](https://forum.kinopio.club/user_avatar/forum.kinopio.club/bentsai/32/8_2.png) [@bentsai](https://forum.kinopio.club/u/bentsai)\
**Post date:** [August 3, 2021, 9:25pm UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/8 "2021-08-03T21:25:54Z")

</div>

I think my proposed algorithm would handle this correctly because it would first split based on new lines, which I assume separate each bullet item. Then you wouldn’t need special logic to detected a numbered list either.

---

<div class="post-metadata">

**Author:** ![pirijan](https://forum.kinopio.club/user_avatar/forum.kinopio.club/pirijan/32/7_2.png) [@pirijan](https://forum.kinopio.club/u/pirijan)\
**Post date:** [August 24, 2021, 12:33am UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/9 "2021-08-24T00:33:59Z")

</div>

i have a fix for this that i’ll ship near the end of the week (when i’m back from break)

it splits by paragraph, then splits a paragraph by sentences if the paragraph is too big, then splits into sentence by 150 chars if the sentence is too big.

here are the test cases and results

```auto
1. First item
2. Second item
3.Third item

```

![Screen Shot 2021-08-23 at 8.29.35 PM](https://forum.kinopio.club/uploads/default/original/1X/2598d5642323684fc1e83e111b2aaa77ba4aabc8.png)

> [@bentsai](#):
>
> ```auto
> 1 In the beginning God created the heavens and the earth. 2 Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters.
> 
> 3 And God said, “Let there be light,” and there was light. 4 God saw that the light was good, and he separated the light from the darkness. 5 God called the light “day,” and the darkness he called “night.” And there was evening, and there was morning—the first day.
> 
> ```

 ![Screen Shot 2021-08-23 at 8.29.39 PM](https://forum.kinopio.club/uploads/default/original/1X/73da0e6ca305e7ea4ec47cc7fd278d0e85aba843.png)

> [@bentsai](#):
>
> ```auto
> :watermelon:Watermelon Ham, The Non-Linear Toolbox, and Your Desktop Pal - The Land of Random (substack.com) 1
> https://stegriff.co.uk/upblog/web-pages-with-personality/ 1 and https://stegriff.co.uk/upblog/baby-griff/
> https://tiv.today/2021/06/kinopio 2
> https://design.futureland.tv/vin/futureland-design/82632?fullscreen=1
> 
> ```

 ![Screen Shot 2021-08-23 at 8.29.44 PM](https://forum.kinopio.club/uploads/default/original/1X/b762adcbe7d3195d82afa35602ea26a458b1775b.png)

---

<div class="post-metadata">

**Author:** ![pirijan](https://forum.kinopio.club/user_avatar/forum.kinopio.club/pirijan/32/7_2.png) [@pirijan](https://forum.kinopio.club/u/pirijan)\
**Post date:** [August 24, 2021, 12:34am UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/10 "2021-08-24T00:34:13Z")

</div>

feel free to provide additional test cases in the meantime

---

<div class="post-metadata">

**Author:** ![bentsai](https://forum.kinopio.club/user_avatar/forum.kinopio.club/bentsai/32/8_2.png) [@bentsai](https://forum.kinopio.club/u/bentsai)\
**Post date:** [August 26, 2021, 1:10am UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/11 "2021-08-26T01:10:21Z")

</div>

Here is a test cases that currently fails (in my opinion):

```auto
Elegent pay duty spectacular price treat also price messy. Industry go space juicy, clean mountain the fast handling crystals. Zesty proven advertising and, aroma, rich. 

The, grab easily challenge full affordable burst absorbent, terrific bigger any our buy improved sleek. Boast inside however, makes gentle double. Special, screamin' you advertising any extravaganza high. 

```

- Current behavior: option to split into 6 cards.
- Desired behavior: option to split into 2 cards
- Rationale: This is two paragraphs of text. Paragraphs are an atomic unit of thought. We shouldn’t break them up unless they are longer than the max characters. Doing so loses information. If a paragraph _is_ too long, then the behavior is more ambiguous, and any of these seem okay:
  - break it apart into sentences
  - break it apart into sentences, but from the last one, keeping as many sentences together as possible.
  - if it’s only one sentence, break it up at the nearest word boundary.

---

<div class="post-metadata">

**Author:** ![bentsai](https://forum.kinopio.club/user_avatar/forum.kinopio.club/bentsai/32/8_2.png) [@bentsai](https://forum.kinopio.club/u/bentsai)\
**Post date:** [August 26, 2021, 1:18am UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/12 "2021-08-26T01:18:22Z")

</div>

> [@bentsai](#):
>
> ```auto
> 1 In the beginning God created the heavens and the earth. 2 Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters.
> 
> 3 And God said, “Let there be light,” and there was light. 4 God saw that the light was good, and he separated the light from the darkness. 5 God called the light “day,” and the darkness he called “night.” And there was evening, and there was morning—the first day.
> 
> ```

I just realized, this is probably the same test case as the Genesis one above, and that you haven’t pushed the fix yet. So let’s see 🙂

---

<div class="post-metadata">

**Author:** ![pirijan](https://forum.kinopio.club/user_avatar/forum.kinopio.club/pirijan/32/7_2.png) [@pirijan](https://forum.kinopio.club/u/pirijan)\
**Post date:** [August 26, 2021, 2:00am UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/13 "2021-08-26T02:00:44Z")

</div>

i haven’t pushed it yet, gonna do QA a bunch of new features tomorrow

> [@bentsai](#):
>
> ```auto
> Elegent pay duty spectacular price treat also price messy. Industry go space juicy, clean mountain the fast handling crystals. Zesty proven advertising and, aroma, rich. 
> 
> The, grab easily challenge full affordable burst absorbent, terrific bigger any our buy improved sleek. Boast inside however, makes gentle double. Special, screamin' you advertising any extravaganza high. 
> 
> ```

with the new code, this creates two cards

---

<div class="post-metadata">

**Author:** ![pirijan](https://forum.kinopio.club/user_avatar/forum.kinopio.club/pirijan/32/7_2.png) [@pirijan](https://forum.kinopio.club/u/pirijan)\
**Post date:** [August 26, 2021, 8:45pm UTC](https://forum.kinopio.club/t/bug-in-card-splitting-logic/372/14 "2021-08-26T20:45:03Z")

</div>

new splitting logic shipped
