Commit 28865b74 authored by Christof Walther's avatar Christof Walther Committed by Patrick Schlindwein
Browse files

feat: If applied, this commit will add basic intent similarity analysis structures and tests.

GitLab issue #3 "SpaCy - Ähnlichkeit der generierten ID"
parent 4abc0a51
src/ktor-server/test.js
data/testHiglighted.docx
data/~$anges-faq.docx
.vscode/settings.json
src/nlp/.vscode/settings.json
src/ktor-server/.idea/compiler.xml
src/ktor-server/.idea/gradle.xml
src/ktor-server/.idea/ktor-server.iml
src/ktor-server/.idea/misc.xml
from abc import ABC, abstractmethod
#interface for summary strategies
class ISummaryStrategy(ABC):
#id of the suammary strategy
@property
def id(self):
raise NotImplementedError
#summarizes a text
@abstractmethod
def summarize(self, text: str) -> str:
raise NotImplementedError
\ No newline at end of file
from app.summary.summary_strategy_interface import ISummaryStrategy
from unittest import TestCase
#valid implementation of ISummaryStrategy
class TestImplementationValid(ISummaryStrategy):
id = "id1"
def summarize(self, text:str) -> str:
return text
#invalid implementation of ISummaryStrategy, missing id definition
class TestImplementationInvalidOne(ISummaryStrategy):
def summarize(self, text:str) -> str:
return text
#actual test case
class TestISummaryStrategy(TestCase):
def test_valid_implementation(self):
#init test data
test_text = "this is a test text"
test_id = "id1"
#run test functions
ti = TestImplementationValid()
summary = ti.summarize(test_text)
#assert result
self.assertEqual(summary, test_text)
self.assertEqual(ti.id, test_id)
def test_invalid_implementation_1(self):
#run test functions
excepted = False
try:
ti = TestImplementationInvalidOne()
ti.id
except NotImplementedError:
excepted = True
#assert result
self.assertTrue(excepted)
\ No newline at end of file
......@@ -61,4 +61,4 @@ class IntentHandler:
# """
# # text = re.sub('<[^>]*>', '', text) to remove html tags
# text = re.sub('[\W]+', '', text.lower())
# return text
\ No newline at end of file
# return text
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment