nebius/SWE-bench-extra huggingface dataset:
Repository: nagisc007/storybuilder

Issue:
Need to fix: append head break line at scene head
シーン冒頭、前に一行開ける
===

**Description**
action出力にて、シーン冒頭のマークダウン、もう一行前も開けておく


Comments:

Patch:
diff --git a/builder/tools.py b/builder/tools.py
index d67e47e..119a5d3 100644
--- a/builder/tools.py
+++ b/builder/tools.py
@@ -298,5 +298,5 @@ def _story_title_of(act: TagAction, level: int) -> str:
     assert isinstance(act, TagAction), "act Must be TagAction class!"
     assert isinstance(level, int), "level Must be int!"
 
-    return "{} {}\n".format("#" * level, act.note)
+    return "{}{} {}\n".format("\n" if level > 1 else "", "#" * level, act.note)
 


Test patch:
diff --git a/tests/test_tools.py b/tests/test_tools.py
index a6530a4..90ca074 100644
--- a/tests/test_tools.py
+++ b/tests/test_tools.py
@@ -87,7 +87,7 @@ class PrivateMethodsTest(unittest.TestCase):
         data = [
                 (self.ma.comment("test"), GroupType.STORY, 1, "<!--test-->"),
                 (self.ma.title("test"), GroupType.STORY, 1, "# test\n"),
-                (self.ma.title("test"), GroupType.STORY, 2, "## test\n"),
+                (self.ma.title("test"), GroupType.STORY, 2, "\n## test\n"),
                 (self.ma.title("test"), GroupType.SCENE, 1, "**test**"),
                 (self.ma.hr(), GroupType.STORY, 1, "--------" * 9),
                 ]
@@ -325,7 +325,7 @@ class PrivateMethodsTest(unittest.TestCase):
         data = [
                 ("a test", 0, " a test\n"),
                 ("a test", 1, "# a test\n"),
-                ("a test", 2, "## a test\n"),
+                ("a test", 2, "\n## a test\n"),
                 ]
 
         for title, lv, expected in data:
Repository: nagisc007/storybuilder

Issue:
Need to fix: unreplaced maru and ten
「。、」が放置されてしまっているので修正
===

**Description**
Description中の「。」で終わるものが「。、」になるが、それが放置されたままなので修正


Comments:

Patch:
diff --git a/builder/commons.py b/builder/commons.py
index 720a692..de6ab2d 100644
--- a/builder/commons.py
+++ b/builder/commons.py
@@ -74,7 +74,7 @@ def extraspace_chopped(target: str, lang: LangType) -> str:
     assert_isclass(lang, LangType)
 
     if lang is LangType.JPN:
-        return re.sub(r'。　(.)', r'。\1', target)
+        return re.sub(r'。[　、](.)', r'。\1', target)
     else:
         return re.sub(r'\s+', r' ', target)
 


Test patch:
diff --git a/tests/test_commons.py b/tests/test_commons.py
index edb3166..d31cac1 100644
--- a/tests/test_commons.py
+++ b/tests/test_commons.py
@@ -134,6 +134,8 @@ class PublicMethodsTest(unittest.TestCase):
                     "　これを。ただしくする。"),
                 (" This is a pen.  the pen. ", LangType.ENG,
                     " This is a pen. the pen. "),
+                ("　これを。、ただしくして。", LangType.JPN,
+                    "　これを。ただしくして。"),
                 ]
 
         for v, lng, expected in data:
Repository: nagisc007/storybuilder

Issue:
Need to fix: combine bug
combine bug display one line
===

**Description**
Combineすると全て１文字ずつで改行されて、縦に一行表示みたいになる


Comments:

Patch:
diff --git a/builder/tools.py b/builder/tools.py
index 82180f7..cf97ad0 100644
--- a/builder/tools.py
+++ b/builder/tools.py
@@ -367,7 +367,7 @@ def _story_converted_as_description_in_group(group: ActionGroup, group_type: Gro
             if val:
                 tmp.append(val)
     if group_type is GroupType.COMBI:
-        return extraspace_chopped("".join(tmp), group.lang)
+        return [extraspace_chopped("".join(tmp), group.lang),]
     else:
         return tmp
 


Test patch:
diff --git a/tests/test_tools.py b/tests/test_tools.py
index 0c003c1..bbbcc7c 100644
--- a/tests/test_tools.py
+++ b/tests/test_tools.py
@@ -340,23 +340,17 @@ class PrivateMethodsTest(unittest.TestCase):
 
 
     def test_story_converted_as_description_in_group(self):
-        self.assertEqual(tools._story_converted_as_description_in_group(self.story, self.story.group_type, 1, False),
-                ["# Taro and Hanako\n",
-                    " a cute girl come in. ",
-                    ' "Nice to meet you" ',
-                    ' "I\'m not fine" '])
-
-    def test_story_converted_as_description_in_group_with_combi(self):
-        ma = Master('test')
         data = [
-                (ma.story(self.taro.talk().d("test"), self.hanako.talk().d("apple")),
+                (self.ma.story("Taro and Hanako", self.taro.talk().d("test"), self.hanako.talk().d("apple"), lang=LangType.ENG),
+                    GroupType.STORY,
+                    ["# Taro and Hanako\n", " test. ", " apple. "]),
+                (self.ma.story(self.taro.talk().d("test"), self.hanako.talk().d("apple")),
                     GroupType.COMBI,
-                    "　test。apple。"),
-                (ma.story(self.taro.talk().d("test"), self.hanako.talk().d("apple"), lang=LangType.ENG),
+                    ["　test。apple。"]),
+                (self.ma.story(self.taro.talk().d("test"), self.hanako.talk().d("apple"), lang=LangType.ENG),
                     GroupType.COMBI,
-                    " test. apple. "),
+                    [" test. apple. "]),
                 ]
-
         for v, gtype, expected in data:
             with self.subTest(v=v, gtype=gtype, expected=expected):
                 self.assertEqual(tools._story_converted_as_description_in_group(
Repository: nagisc007/storybuilder

Issue:
Check: character count when combined
combine した時にちゃんと行と文字数がカウントできているか
===

**Description**
combine時の確認。
間違っていたら修正。


Comments:

Patch:
diff --git a/builder/buildtool.py b/builder/buildtool.py
index 5c005fe..08449e3 100644
--- a/builder/buildtool.py
+++ b/builder/buildtool.py
@@ -271,7 +271,7 @@ def _manupaper_rows_from_(val, lang: em.LangType, columns: int) -> int:
     elif isinstance(val, act.TagAction):
         return 0
     elif isinstance(val, act.Action):
-        return utl.int_ceiled(_descs_count_from_(val, lang), columns)
+        return _descs_count_from_(val, lang)
     else:
         return 0
 
@@ -279,7 +279,10 @@ def _manupaper_rows_from_(val, lang: em.LangType, columns: int) -> int:
 def _manupaper_rows_from_in(vals: [act.ActionGroup, list, tuple],
         lang: em.LangType, columns: int) -> int:
     group = vals.actions if isinstance(vals, act.ActionGroup) else vals
-    return sum([_manupaper_rows_from_(v, lang, columns) for v in group])
+    if isinstance(vals, act.ActionGroup) and vals.group_type is em.GroupType.COMBI:
+        return utl.int_ceiled(sum(_manupaper_rows_from_(v, lang, columns) for v in group), columns)
+    else:
+        return sum([utl.int_ceiled(_manupaper_rows_from_(v, lang, columns), columns) for v in group])
 
 
 def _maintitle_from(story: list) -> list:


Test patch:
diff --git a/tests/test_buildtool.py b/tests/test_buildtool.py
index c794c9b..b873256 100644
--- a/tests/test_buildtool.py
+++ b/tests/test_buildtool.py
@@ -157,6 +157,25 @@ class PrivateMethodsTest(unittest.TestCase):
             with self.subTest(v=v, lang=lang, expected=expected):
                 self.assertEqual(btl._estimated_description_count_from(v, lang), expected)
 
+    def test_manupaper_rows_from_in(self):
+        from builder import world
+        w = world.World("test")
+        data = [
+                ((self.taro.be().d("test"), self.taro.be().d("apple"),),
+                    em.LangType.JPN, 20, 2),
+                ((w.combine(
+                    self.taro.be().d("test"), self.taro.be().d("apple"),
+                    ),),
+                    em.LangType.JPN, 20, 1),
+                (w.combine(
+                    self.taro.be().d("test apple"), self.taro.be().d("test orange"),
+                    ),
+                    em.LangType.JPN, 20, 2),
+                ]
+        for v, lang, columns, expected in data:
+            with self.subTest(v=v, lang=lang, columns=columns, expected=expected):
+                self.assertEqual(btl._manupaper_rows_from_in(v, lang, columns), expected)
+
     def test_output_to_console(self):
         data = [
                 (["test"], False,
Repository: nagisc007/storybuilder

Issue:
Need to fix: output actions with act word
act word が表示されない
===

**Description**
仕様変更にともない、actionの出力にact_wordを使うように修正。

**To Reproduce**
nothing

**Expected behavior**
nothing

**Current behavior**
nothing

**Tasks**
- [ ] fix output with act_word
- [ ] fix output_md with act_word
- [ ] pass tests

**Note**
nothing

Comments:

Patch:
diff --git a/builder/tools.py b/builder/tools.py
index 406dfd6..2a990d8 100644
--- a/builder/tools.py
+++ b/builder/tools.py
@@ -17,15 +17,15 @@ def build_action_strings(story, is_debug=False):
     
     for s in story:
         if s.act_type is ActType.SYMBOL:
-            act_str.append("\n## {}\n\n".format(s.action))
+            act_str.append("\n## {}\n\n".format(_action_with_act_word_if_selected(s)))
         elif s.act_type is ActType.DESC or s.act_type is ActType.ACT:
-            act_str.append("{}\n".format(s.action))
+            act_str.append("{}\n".format(_action_with_act_word_if_selected(s)))
         elif s.act_type is ActType.TELL:
-            act_str.append("「{}」\n".format(s.action))
+            act_str.append("「{}」{}\n".format(s.action, s.act_word))
         elif s.act_type is ActType.THINK:
-            act_str.append("{}\n".format(s.action))
+            act_str.append("{}\n".format(_action_with_act_word_if_selected(s)))
         elif s.act_type is ActType.TEST and is_debug:
-            act_str.append("> TEST:{}\n".format(s.action))
+            act_str.append("> TEST:{}\n".format(_action_with_act_word_if_selected(s)))
         else:
             pass
 
@@ -100,3 +100,12 @@ def _description_selected(act):
         return act.description
     return act.action
 
+
+def _action_with_act_word_if_selected(act):
+    '''Action string created with selecting act word.
+
+    Returns:
+        str: action string.
+    '''
+    return "{}{}".format(act.action, act.act_word) if act.with_act else act.action
+


Test patch:
diff --git a/tests/test_tools.py b/tests/test_tools.py
index 9b6da20..aec9622 100644
--- a/tests/test_tools.py
+++ b/tests/test_tools.py
@@ -12,7 +12,7 @@ from builder.tools import build_description_strings
 from builder.tools import output
 from builder.tools import output_md
 from builder.tools import _description_selected
-
+from builder.tools import _action_with_act_word_if_selected
 
 class TestTools(unittest.TestCase):
 
@@ -41,6 +41,13 @@ class TestTools(unittest.TestCase):
 
         self.assertEqual(_description_selected(normal_act), "go to room")
 
+    def test__action_with_act_word_if_selected(self):
+        noselected = Act(self.taro, ActType.ACT, Behavior.GO, "to room", " go", with_act=False)
+        selected = Act(self.taro, ActType.ACT, Behavior.GO, "to room", " go", with_act=True)
+
+        self.assertEqual(_action_with_act_word_if_selected(noselected), "to room")
+        self.assertEqual(_action_with_act_word_if_selected(selected), "to room go")
+
     def test__description_selected_with_description(self):
         normal_act = Act(self.taro, ActType.ACT, Behavior.GO, "go to room")
         act_with_desc = normal_act.desc("walk so slowly to the room")