Skip to content

Commit e65ef79

Browse files
authored
Merge pull request RasaHQ#4718 from yulkes/bugfix_allow_colon_in_section_title
Support Markdown sections where the title contains the delimiter (:)
2 parents 21b854a + ce199ff commit e65ef79

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## synonym:10:00
2+
- 10:00 am

rasa/nlu/training_data/formats/markdown.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def _strip_comments(text: Text) -> Text:
8989
def _find_section_header(self, line: Text) -> Optional[Tuple[Text, Text]]:
9090
"""Checks if the current line contains a section header
9191
and returns the section and the title."""
92-
match = re.search(r"##\s*(.+):(.+)", line)
92+
match = re.search(r"##\s*(.+?):(.+)", line)
9393
if match is not None:
9494
return match.group(1), match.group(2)
9595

tests/nlu/base/test_training_data.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,3 +588,10 @@ def test_markdown_not_existing_section():
588588
training_data.load_data(
589589
"data/test/markdown_single_sections/not_existing_section.md"
590590
)
591+
592+
593+
def test_section_value_with_delimiter():
594+
td_section_with_delimiter = training_data.load_data(
595+
"data/test/markdown_single_sections/section_with_delimiter.md"
596+
)
597+
assert td_section_with_delimiter.entity_synonyms == {"10:00 am": "10:00"}

0 commit comments

Comments
 (0)