Skip to content

Commit

Permalink
fix:typing and docstrs
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Oct 16, 2024
1 parent 8fd1df8 commit 82f2ba1
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 11 deletions.
3 changes: 1 addition & 2 deletions ovos_padatious/__main__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import inspect
import json
from os.path import basename, splitext

from argparse import ArgumentParser
from os.path import basename, splitext

from ovos_padatious import IntentContainer

Expand Down
2 changes: 1 addition & 1 deletion ovos_padatious/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from os.path import join
from typing import Any, Dict, Type
from typing import Any, Type

from ovos_padatious.simple_intent import SimpleIntent
from ovos_padatious.trainable import Trainable
Expand Down
3 changes: 2 additions & 1 deletion ovos_padatious/entity_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import List, Any, Callable, Tuple
from typing import List, Any, Callable

from fann2 import libfann as fann

from ovos_padatious.id_manager import IdManager
Expand Down
2 changes: 1 addition & 1 deletion ovos_padatious/id_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import json
from typing import Optional, Dict, List, Any
from typing import Optional, Dict, List

from ovos_padatious.util import StrEnum

Expand Down
2 changes: 1 addition & 1 deletion ovos_padatious/intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import json
import math
from os.path import join
from typing import List, Optional, Union
from typing import List, Optional

from ovos_padatious.match_data import MatchData
from ovos_padatious.pos_intent import PosIntent
Expand Down
2 changes: 2 additions & 0 deletions ovos_padatious/intent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from typing import List, Dict, Any, Optional

from ovos_utils.log import LOG

from ovos_padatious import padaos
from ovos_padatious.entity import Entity
from ovos_padatious.entity_manager import EntityManager
Expand All @@ -33,6 +34,7 @@ def _save_args(func):
Args:
func (function): The function to be decorated.
"""

@wraps(func)
def wrapper(*args, **kwargs) -> None:
func(*args, **kwargs)
Expand Down
3 changes: 2 additions & 1 deletion ovos_padatious/intent_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import List, Optional, Any

from ovos_padatious.intent import Intent
from ovos_padatious.match_data import MatchData
from ovos_padatious.training_manager import TrainingManager
from ovos_padatious.util import tokenize
from typing import List, Optional, Any


class IntentManager(TrainingManager):
Expand Down
1 change: 1 addition & 0 deletions ovos_padatious/padaos.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
from threading import Lock
from typing import Dict, List, Optional, Union, Iterator

from ovos_utils.log import LOG


Expand Down
2 changes: 1 addition & 1 deletion ovos_padatious/pos_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import math
from typing import List, Tuple, Dict, Optional, Any
from typing import List, Optional, Any

from ovos_padatious.entity_edge import EntityEdge
from ovos_padatious.match_data import MatchData
Expand Down
2 changes: 2 additions & 0 deletions ovos_padatious/simple_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

from typing import List, Optional

from fann2 import libfann as fann

from ovos_padatious.id_manager import IdManager
Expand Down Expand Up @@ -107,6 +108,7 @@ def pollute(sent: List[str], p: int) -> None:

def weight(sent: List[str]) -> None:
"""Calculates and adds weights for the words in a sentence."""

def calc_weight(w: str) -> float:
return pow(len(w), 3.0)

Expand Down
2 changes: 1 addition & 1 deletion ovos_padatious/training_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from ovos_utils.log import LOG

import ovos_padatious
from ovos_padatious.trainable import Trainable
from ovos_padatious.train_data import TrainData
from ovos_padatious.trainable import Trainable
from ovos_padatious.util import lines_hash


Expand Down
6 changes: 4 additions & 2 deletions ovos_padatious/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
# limitations under the License.

from xxhash import xxh32
from typing import List, Tuple, Dict, Any

# keep import for backwards compat
from ovos_utils.bracket_expansion import SentenceTreeParser, expand_parentheses
from typing import List, Tuple, Dict, Any


def lines_hash(lines: List[str]) -> bytes:
Expand Down Expand Up @@ -86,7 +87,8 @@ def remove_comments(lines: List[str]) -> List[str]:
return [line for line in lines if not line.startswith('//')]


def resolve_conflicts(inputs: List[List[float]], outputs: List[List[float]]) -> Tuple[List[List[float]], List[List[float]]]:
def resolve_conflicts(inputs: List[List[float]], outputs: List[List[float]]) -> Tuple[
List[List[float]], List[List[float]]]:
"""
Resolves conflicts in the input/output pairs by removing duplicates
and combining output vectors for duplicate inputs.
Expand Down

0 comments on commit 82f2ba1

Please sign in to comment.