Add pipeline engine and remove legacy compatibility paths
This commit is contained in:
parent
3bc473262d
commit
e221d49020
18 changed files with 1523 additions and 399 deletions
|
|
@ -7,18 +7,17 @@ SRC = ROOT / "src"
|
|||
if str(SRC) not in sys.path:
|
||||
sys.path.insert(0, str(SRC))
|
||||
|
||||
from config import DomainInferenceConfig, VocabularyConfig, VocabularyReplacement
|
||||
from vocabulary import DOMAIN_GENERAL, VocabularyEngine
|
||||
from config import VocabularyConfig, VocabularyReplacement
|
||||
from vocabulary import VocabularyEngine
|
||||
|
||||
|
||||
class VocabularyEngineTests(unittest.TestCase):
|
||||
def _engine(self, replacements=None, terms=None, domain_enabled=True):
|
||||
def _engine(self, replacements=None, terms=None):
|
||||
vocab = VocabularyConfig(
|
||||
replacements=replacements or [],
|
||||
terms=terms or [],
|
||||
)
|
||||
domain = DomainInferenceConfig(enabled=domain_enabled)
|
||||
return VocabularyEngine(vocab, domain)
|
||||
return VocabularyEngine(vocab)
|
||||
|
||||
def test_boundary_aware_replacement(self):
|
||||
engine = self._engine(
|
||||
|
|
@ -50,27 +49,5 @@ class VocabularyEngineTests(unittest.TestCase):
|
|||
self.assertLessEqual(len(hotwords), 1024)
|
||||
self.assertLessEqual(len(prompt), 600)
|
||||
|
||||
def test_domain_inference_general_fallback(self):
|
||||
engine = self._engine()
|
||||
result = engine.infer_domain("please call me later")
|
||||
|
||||
self.assertEqual(result.name, DOMAIN_GENERAL)
|
||||
self.assertEqual(result.confidence, 0.0)
|
||||
|
||||
def test_domain_inference_for_technical_text(self):
|
||||
engine = self._engine(terms=["Docker", "Systemd"])
|
||||
result = engine.infer_domain("restart Docker and systemd service on prod")
|
||||
|
||||
self.assertNotEqual(result.name, DOMAIN_GENERAL)
|
||||
self.assertGreater(result.confidence, 0.0)
|
||||
|
||||
def test_domain_inference_can_be_disabled(self):
|
||||
engine = self._engine(domain_enabled=False)
|
||||
result = engine.infer_domain("please restart docker")
|
||||
|
||||
self.assertEqual(result.name, DOMAIN_GENERAL)
|
||||
self.assertEqual(result.confidence, 0.0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue