Skip to content

Commit

Permalink
style: lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
ltbringer committed Feb 12, 2022
1 parent fd26dd4 commit a6bed6d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
28 changes: 14 additions & 14 deletions dialogy/base/plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,20 @@

class Plugin(ABC):
"""
Abstract class to be implemented by all plugins.
:param input_column: Transforms data in this column for a given dataframe, defaults to const.ALTERNATIVES
:type input_column: str
:param output_column: Saves transformation in this column for a given dataframe, defaults to None
:type output_column: Optional[str]
:param use_transform: Should the transformation be applied while training?, defaults to False
:type use_transform: bool
:param dest: The path where plugin output should be saved., defaults to None
:type dest: Optional[str]
:param guards: A list of functions that evaluate to bool, defaults to None
:type guards: Optional[List[Guard]]
:param debug: Should we print debug logs?, defaults to False
:type debug: bool, optional
Abstract class to be implemented by all plugins.
:param input_column: Transforms data in this column for a given dataframe, defaults to const.ALTERNATIVES
:type input_column: str
:param output_column: Saves transformation in this column for a given dataframe, defaults to None
:type output_column: Optional[str]
:param use_transform: Should the transformation be applied while training?, defaults to False
:type use_transform: bool
:param dest: The path where plugin output should be saved., defaults to None
:type dest: Optional[str]
:param guards: A list of functions that evaluate to bool, defaults to None
:type guards: Optional[List[Guard]]
:param debug: Should we print debug logs?, defaults to False
:type debug: bool, optional
"""

def __init__(
Expand Down
4 changes: 3 additions & 1 deletion dialogy/plugins/text/slot_filler/rule_slot_filler.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def __init__(
# ```
# rules = {"intent": {"slot_name": "entity_type"}}
# ```
super().__init__(dest=dest, guards=guards, debug=debug, replace_output=replace_output)
super().__init__(
dest=dest, guards=guards, debug=debug, replace_output=replace_output
)
self.rules: Rule = rules or {}

# fill_multiple
Expand Down
24 changes: 17 additions & 7 deletions dialogy/workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,27 @@ def set(self, path: str, value: Any, replace: bool = False) -> Workflow:
elif dest == "output" and isinstance(value, list):

if replace:
self.output = Output.from_dict({attribute: value}, reference=self.output)
self.output = Output.from_dict(
{attribute: value}, reference=self.output
)
else:
if attribute == const.INTENTS:
previous_value = self.output.intents # type: ignore
previous_value = self.output.intents # type: ignore
elif attribute == const.ENTITIES:
previous_value = self.output.entities # type: ignore
previous_value = self.output.entities # type: ignore
else:
raise ValueError(f"Unknown attribute {attribute} tracked on Output.")

combined_value = sorted(previous_value + value, key=lambda parse: parse.score or 0, reverse=True)
self.output = Output.from_dict({attribute: combined_value}, reference=self.output)
raise ValueError(
f"Unknown attribute {attribute} tracked on Output."
)

combined_value = sorted(
previous_value + value,
key=lambda parse: parse.score or 0,
reverse=True,
)
self.output = Output.from_dict(
{attribute: combined_value}, reference=self.output
)

elif dest == "output":
raise ValueError(f"{value=} should be a List[Intent] or List[BaseEntity].")
Expand Down

0 comments on commit a6bed6d

Please sign in to comment.