stark-engine 4.5.3__tar.gz → 4.5.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. {stark_engine-4.5.3 → stark_engine-4.5.4}/PKG-INFO +1 -1
  2. {stark_engine-4.5.3 → stark_engine-4.5.4}/pyproject.toml +1 -1
  3. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/parsing.py +6 -4
  4. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/types/object.py +10 -5
  5. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/feature_flags.py +2 -0
  6. {stark_engine-4.5.3 → stark_engine-4.5.4}/LICENSE.md +0 -0
  7. {stark_engine-4.5.3 → stark_engine-4.5.4}/README.md +0 -0
  8. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/__init__.py +0 -0
  9. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/__init__.py +0 -0
  10. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/command.py +0 -0
  11. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/commands_context.py +0 -0
  12. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/commands_context_processor.py +0 -0
  13. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/commands_manager.py +0 -0
  14. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/health_check.py +0 -0
  15. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/patterns/__init__.py +0 -0
  16. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/patterns/pattern.py +0 -0
  17. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/patterns/rules.py +0 -0
  18. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/processors/__init__.py +0 -0
  19. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/processors/corrections_processor.py +0 -0
  20. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/processors/search_processor.py +0 -0
  21. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/processors/spacy_ner_processor.py +0 -0
  22. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/types/__init__.py +0 -0
  23. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/types/location.py +0 -0
  24. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/types/slots.py +0 -0
  25. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/types/string.py +0 -0
  26. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/types/union.py +0 -0
  27. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/core/types/word.py +0 -0
  28. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/blockage_detector.py +0 -0
  29. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/cache.py +0 -0
  30. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/classproperty.py +0 -0
  31. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/dependencies.py +0 -0
  32. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/json_encoder.py +0 -0
  33. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/localisation/__init__.py +0 -0
  34. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/localisation/language_code.py +0 -0
  35. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/localisation/locale_string.py +0 -0
  36. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/localisation/localizable_string.py +0 -0
  37. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/localisation/localizer.py +0 -0
  38. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/general/localisation/strings.py +0 -0
  39. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/interfaces/gcloud.py +0 -0
  40. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/interfaces/microphone.py +0 -0
  41. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/interfaces/protocols.py +0 -0
  42. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/interfaces/recognizer_relay.py +0 -0
  43. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/interfaces/silero.py +0 -0
  44. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/interfaces/vosk.py +0 -0
  45. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/models/__init__.py +0 -0
  46. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/models/transcription_string.py +0 -0
  47. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/models/voice_transcription.py +0 -0
  48. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/models/voice_transcription_string.py +0 -0
  49. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/common/span.py +0 -0
  50. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/dictionary/!examples.py +0 -0
  51. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/dictionary/__init__.py +0 -0
  52. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/dictionary/dictionary.py +0 -0
  53. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/dictionary/models.py +0 -0
  54. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/dictionary/nl_dictionary_name.py +0 -0
  55. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/dictionary/recognizable_dictionary.py +0 -0
  56. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/dictionary/storage/__init__.py +0 -0
  57. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/dictionary/storage/storage_memory.py +0 -0
  58. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/dictionary/storage/storage_sqlite.py +0 -0
  59. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/levenshtein/__init__.py +0 -0
  60. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/levenshtein/levenshtein.pyi +0 -0
  61. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/levenshtein/levenshtein.pyx +0 -0
  62. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/phonetic/simplephone.py +0 -0
  63. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/phonetic/transcription/__init__.py +0 -0
  64. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/phonetic/transcription/epitran.py +0 -0
  65. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/phonetic/transcription/espeak.py +0 -0
  66. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/phonetic/transcription/ipa2lat.py +0 -0
  67. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/phonetic/transcription/latin_passthrough.py +0 -0
  68. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/phonetic/transcription/protocol.py +0 -0
  69. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/sliding_window_parser.py +0 -0
  70. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/tools/strtools.py +0 -0
  71. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/voice_assistant/__init__.py +0 -0
  72. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/voice_assistant/mode.py +0 -0
  73. {stark_engine-4.5.3 → stark_engine-4.5.4}/stark/voice_assistant/voice_assistant.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stark-engine
3
- Version: 4.5.3
3
+ Version: 4.5.4
4
4
  Summary: S.T.A.R.K - Speech and Text Algorithmic Recognition Kit. Modern framework for creating powerfull voice assistants.
5
5
  License: CC BY-NC-SA 4.0
6
6
  License-File: LICENSE.md
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "stark-engine"
3
- version = "4.5.3"
3
+ version = "4.5.4"
4
4
  description = "S.T.A.R.K - Speech and Text Algorithmic Recognition Kit. Modern framework for creating powerfull voice assistants."
5
5
  authors = ["MarkParker5 <mark@parker-programs.com>"]
6
6
  license = "CC BY-NC-SA 4.0"
@@ -12,6 +12,7 @@ from stark.core.types.string import String
12
12
  from stark.core.types.union import Union, _all_subclasses
13
13
  from stark.core.types.word import Word
14
14
  from stark.general.cache import alru_cache
15
+ from stark.general.feature_flags import FeatureFlag, get_flag
15
16
  from stark.general.localisation import LanguageCode, LocaleString, Localizer
16
17
  from stark.models.transcription_string import Correction
17
18
  from stark.tools.common.span import Span
@@ -192,7 +193,7 @@ class PatternParser:
192
193
  string = from_string._with(object_pattern_match.substring) # TODO: review _with usage
193
194
 
194
195
  parser: ObjectParser = self.parameter_types_by_name[object_type.__name__].parser
195
- obj = object_type(string) # temp/default value, may be overridden by did_parse
196
+ obj = object_type() # object_type(string) # temp/default value, may be overridden by did_parse
196
197
 
197
198
  matched_subparams = object_pattern_match.parameters
198
199
  assert matched_subparams.keys() <= {p.name for p in pattern.parameters.values() if not p.optional}
@@ -213,9 +214,10 @@ class PatternParser:
213
214
  assert substring in string, ValueError(
214
215
  f"Parsed substring must be a part of the original string. There is no '{substring}' in '{string}'. Object: {obj!r}, Parser: {parser!r}"
215
216
  )
216
- assert obj.value is not None, ValueError(
217
- f"Parsed object {obj!r} must have a `value` property set in did_parse method. Object: {obj!r}, Parser: {parser!r}"
218
- )
217
+ if not get_flag(FeatureFlag.TYPE_NO_REQUIRED_VALUE):
218
+ assert obj.value is not None, ValueError(
219
+ f"Parsed object {obj!r} must have a `value` property set at the time did_parse method returns. Object: {obj!r}, Parser: {parser!r}"
220
+ )
219
221
 
220
222
  yield ParseResult(obj, substring)
221
223
 
@@ -2,7 +2,6 @@ from __future__ import annotations
2
2
 
3
3
  import copy
4
4
  from abc import ABCMeta
5
- from typing import Any
6
5
 
7
6
  from stark.core.patterns.pattern import Pattern
8
7
  from stark.general.classproperty import classproperty
@@ -40,7 +39,7 @@ class UnionMeta(ABCMeta):
40
39
  # TODO: review programmable init vs did_parse
41
40
  # TODO: consider storing parsing metadata here like substr and span
42
41
  class Object[T](metaclass=UnionMeta):
43
- value: T
42
+ value: T = None
44
43
 
45
44
  @classproperty
46
45
  def pattern(cls) -> Pattern:
@@ -60,9 +59,13 @@ class Object[T](metaclass=UnionMeta):
60
59
  """
61
60
  return False # TODO: review default behavior
62
61
 
63
- def __init__(self, value: Any):
64
- """Just init with wrapped value."""
65
- self.value = value
62
+ def __init__(self, *args, **kwargs):
63
+ """Init with wrapped value, if provided. Otherwise leave `value` untouched so a static
64
+ value set at class declaration time (e.g. `value = "foo"`) survives instantiation."""
65
+ if "value" in kwargs:
66
+ self.value = kwargs["value"]
67
+ elif args:
68
+ self.value = args[0]
66
69
 
67
70
  async def did_parse(self, from_string: LocaleString) -> str:
68
71
  """
@@ -79,6 +82,8 @@ class Object[T](metaclass=UnionMeta):
79
82
  Raises:
80
83
  ParseError: if parsing failed.
81
84
  """
85
+ if not self.value:
86
+ self.value = from_string
82
87
  return from_string
83
88
 
84
89
  def copy(self) -> Object:
@@ -5,11 +5,13 @@ from enum import StrEnum
5
5
  class FeatureFlag(StrEnum):
6
6
  ENABLE_VOICE_CLI = "STARK_ENABLE_VOICE_CLI"
7
7
  ENABLE_MULTILANG_MATRIX = "STARK_ENABLE_MULTILANG_MATRIX"
8
+ TYPE_NO_REQUIRED_VALUE = "STARK_TYPE_NO_REQUIRED_VALUE"
8
9
 
9
10
 
10
11
  _DEFAULTS: dict[FeatureFlag, str] = {
11
12
  FeatureFlag.ENABLE_VOICE_CLI: "0",
12
13
  FeatureFlag.ENABLE_MULTILANG_MATRIX: "1",
14
+ FeatureFlag.TYPE_NO_REQUIRED_VALUE: "0",
13
15
  }
14
16
 
15
17
 
File without changes
File without changes