Skip to content

Commit

Permalink
Merge pull request #657 from snipsco/hotfix/crf-slot-filler-file-name
Browse files Browse the repository at this point in the history
Fix the generation of crf_slot_fillers files names
  • Loading branch information
ClemDoum authored Aug 30, 2018
2 parents 10db554 + 5709c48 commit 4fa6b93
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.16.4] - 2018-08-30
### Fixed
- Issue with the `CrfSlotFiller` file names in the `ProbabilisticIntentParser` serialization

## [0.16.3] - 2018-08-22
### Fixed
Expand Down Expand Up @@ -132,6 +135,7 @@ several commands.
- Fix compiling issue with `bindgen` dependency when installing from source
- Fix issue in `CRFSlotFiller` when handling builtin entities

[0.16.4]: https://github.com/snipsco/snips-nlu/compare/0.16.3...0.16.4
[0.16.3]: https://github.com/snipsco/snips-nlu/compare/0.16.2...0.16.3
[0.16.2]: https://github.com/snipsco/snips-nlu/compare/0.16.1...0.16.2
[0.16.1]: https://github.com/snipsco/snips-nlu/compare/0.16.0...0.16.1
Expand Down
2 changes: 1 addition & 1 deletion snips_nlu/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__email__ = "[email protected], [email protected]"
__license__ = "Apache License, Version 2.0"

__version__ = "0.16.3"
__version__ = "0.16.4"
__model_version__ = "0.16.0"

__download_url__ = "https://github.com/snipsco/snips-nlu-language-resources/releases/download"
Expand Down
8 changes: 3 additions & 5 deletions snips_nlu/intent_parser/probabilistic_intent_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,16 @@ def persist(self, path):
"""Persist the object at the given path"""
path = Path(path)
path.mkdir()
sorted_slot_fillers = sorted(iteritems(self.slot_fillers))
slot_fillers = []
for intent, slot_filler in iteritems(self.slot_fillers):
slot_filler_name = "slot_filler_%s" % intent
for i, (intent, slot_filler) in enumerate(sorted_slot_fillers):
slot_filler_name = "slot_filler_%s" % i
slot_filler.persist(path / slot_filler_name)
slot_fillers.append({
"intent": intent,
"slot_filler_name": slot_filler_name
})

# Only needed to improve testability
slot_fillers = sorted(slot_fillers, key=lambda sf: sf["intent"])

if self.intent_classifier is not None:
self.intent_classifier.persist(path / "intent_classifier")

Expand Down
8 changes: 4 additions & 4 deletions snips_nlu/tests/test_probabilistic_intent_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ def test_should_be_serializable(self):
"slot_fillers": [
{
"intent": "MakeCoffee",
"slot_filler_name": "slot_filler_MakeCoffee"
"slot_filler_name": "slot_filler_0"
},
{
"intent": "MakeTea",
"slot_filler_name": "slot_filler_MakeTea"
"slot_filler_name": "slot_filler_1"
}
]
}
Expand All @@ -168,10 +168,10 @@ def test_should_be_serializable(self):
self.tmp_file_path / "intent_classifier" / "metadata.json",
metadata_intent_classifier)
self.assertJsonContent(
self.tmp_file_path / "slot_filler_MakeCoffee" / "metadata.json",
self.tmp_file_path / "slot_filler_0" / "metadata.json",
metadata_slot_filler)
self.assertJsonContent(
self.tmp_file_path / "slot_filler_MakeTea" / "metadata.json",
self.tmp_file_path / "slot_filler_1" / "metadata.json",
metadata_slot_filler)

def test_should_be_deserializable(self):
Expand Down

0 comments on commit 4fa6b93

Please sign in to comment.