Nikos Atlas 2 年 前
コミット
b8d321a8a9

+ 0 - 0
src/__init__.py


+ 0 - 0
__tests__/test.py → src/__tests__/test.py


+ 9 - 3
__tests__/test_leaf_strategy.py → src/__tests__/test_leaf_strategy.py

@@ -3,7 +3,8 @@ import pytest
 import spacy
 from spacy import displacy
 
-from src.strategies.leaf_strategy import leaf_strategy
+from src.generators import Generator
+from src.strategies import leaf_strategy
 
 nlp = spacy.load("en_core_web_trf")
 
@@ -11,8 +12,13 @@ nlp = spacy.load("en_core_web_trf")
     ('Regex for redacted phone numbers with extra info for PlayStation', ['PhoneNumberRegex', 'RedactedPhoneNumberRegex'])
 ])
 def test_leaf_strategy(text, expected):
-    doc = nlp(text)
+    generator = Generator(text=text, strategy=leaf_strategy)
 
-    result = leaf_strategy(doc)
+    results = generator.suggest()
 
+    doc = generator.doc
+    for token in doc:
+        print(token)
+
+    print(results)
     # assert result == expected

+ 5 - 0
src/generators/__init__.py

@@ -0,0 +1,5 @@
+from .generator import Generator
+
+__all__ = [
+    'Generator',
+]

+ 4 - 0
src/generators/generator.py

@@ -10,8 +10,12 @@ class Generator():
         :return:
 
     """
+
+    # passed text
     text = None
+    # parsed text from spacy lib
     doc = None
+    # the strategy resolver to use
     strategy_resolver = None
 
     def __init__(self, text=None, strategy=None):

+ 5 - 0
src/strategies/__init__.py

@@ -0,0 +1,5 @@
+from .leaf_strategy import leaf_strategy
+
+__all__ = [
+    'leaf_strategy',
+]

+ 5 - 0
src/utils/__init__.py

@@ -0,0 +1,5 @@
+from .word_helpers import WordHelpers
+
+__all__ = [
+    'WordHelpers',
+]

+ 25 - 22
src/utils/word_helpers.py

@@ -1,30 +1,33 @@
-def camel_case(word):
-    pass
 
+class WordHelpers():
+    @staticmethod
+    def camel_case(word):
+        pass
 
-def upper_case(word):
-    pass
+    @staticmethod
+    def upper_case(word):
+        pass
 
+    @staticmethod
+    def snake_case(word):
+        pass
 
-def snake_case(word):
-    pass
+    @staticmethod
+    def constants(word):
+        return WordHelpers.upper_case(WordHelpers.snake_case(word))
 
+    @staticmethod
+    def variable(word):
+        pass
 
-def constants(word):
-    return upper_case(snake_case(word))
+    @staticmethod
+    def function(word):
+        pass
 
+    @staticmethod
+    def classname(word):
+        pass
 
-def variable(word):
-    pass
-
-
-def function(word):
-    pass
-
-
-def classname(word):
-    pass
-
-
-def method(word):
-    pass
+    @staticmethod
+    def method(word):
+        pass