Skip to content
This repository has been archived by the owner on Jun 12, 2021. It is now read-only.

Commit

Permalink
adding .env
Browse files Browse the repository at this point in the history
  • Loading branch information
jawahar273 committed Sep 29, 2018
1 parent d187a9b commit 9719ac9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
1 change: 0 additions & 1 deletion .pytest_cache/v/cache/nodeids
@@ -1,4 +1,3 @@
[
"tests/test_annotator.py::TestAnnotator::()::test_pos",
"tests/test_pntl.py::test_content"
]
19 changes: 14 additions & 5 deletions pntl/db/model.py
@@ -1,13 +1,12 @@
""" Database class are declare in the file.
"""
from os import getenv

from sqlalchemy import Column, Integer, String, UnicodeText

from pntl.db.config import Base
from pntl.db.json_field import JSONEncodedDict

from pntl.utils import pntl_hash, env_int
from pntl.utils import pntl_hash, env_int, env_str


def _json_field(value):
Expand All @@ -22,12 +21,11 @@ def _json_field(value):
return JSONEncodedDict(value)


class Package(Base):
class AbstractPackage(Base):

__tablename__ = getenv("TABLENAME", "content")
__abstract__ = True

id = Column(Integer, primary_key=True)

words = Column(UnicodeText())
syntax_tree = Column(UnicodeText())
pos = Column(_json_field(env_int("POS_LEN")))
Expand All @@ -36,6 +34,12 @@ class Package(Base):
srl = Column(_json_field(env_int("SRL_LEN")))
chunk = Column(_json_field(env_int("CHUNK_LEN")))
verbs = Column(_json_field(env_int("VERB_LEN")))


class Package(AbstractPackage):

__tablename__ = env_str("TABLENAME", "same_pc")

hash_str = Column(String(env_int("HASH_VALUE_LEN", 20)), unique=True)

def __init__(self, words, syntax_tree, pos, ner, dep_parse, srl, chunk, verbs):
Expand All @@ -49,3 +53,8 @@ def __init__(self, words, syntax_tree, pos, ner, dep_parse, srl, chunk, verbs):
self.chunk = chunk
self.verbs = verbs
self.hash_str = pntl_hash(words)


class DistPackage(AbstractPackage):

__tablename__ = env_str("TABLENAME", "dist")
4 changes: 2 additions & 2 deletions pntl/db/search/config.py
@@ -1,11 +1,11 @@
# Elastic Search is been used as
# search engine.
from os import getenv
from json import loads

from elasticsearch_dsl import connections
from pntl.utils import env_str


def connect():

connections.create_connection(**loads(getenv("ELASTICSEARCH_HOST")))
connections.create_connection(**loads(env_str("ELASTICSEARCH_HOST")))
3 changes: 3 additions & 0 deletions pntl/db/search/engine.py
Expand Up @@ -9,6 +9,9 @@ class ElasticEngine(AbstractEngine):
"""docstring for SearchEngine"""

def __init__(self, arg):

config.connect()

AnnotatorElastic().init()

def insert(self, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion pntl/senna/in.parse
@@ -1 +1 @@
(S1(S(NP(PRP He))(VP(VP(VBD created)(NP(DT the)(NN robot)))(CC and)(VP(VBD broke)(NP(PRP it))(PP(IN after)(S(VP(VBG making)(NP(PRP it)))))))))
(S1(S(NP(NNP PgAdmin))(VP(VBZ is)(NP(NP(DT the)(VBG leading)(NNP Open)(NNP Source)(NN management)(NN tool))(PP(IN for)(NP(NP(NNP Postgres))(, ,)(NP(DT the)(NN world))(VBZ s)(ADJP(RBS most)(JJ advanced))(NNP Open)(NNP Source)(NN database)))))(. .)))
6 changes: 1 addition & 5 deletions tests/test_annotator.py
Expand Up @@ -8,7 +8,7 @@
class TestAnnotator:
def setup(self):

self.sent = "He created the robot and broke it after making it"
self.sent = "PgAdmin is the leading Open Source management tool for Postgres, the world’s most advanced Open Source database."
args = {"senna_dir": self.get_senna_path("pntl", "senna"), "save_all": True}
self.annotator = Annotator(**args)
self.process = self.annotator.get_annoations(self.sent, dep_parse=True)
Expand All @@ -18,7 +18,3 @@ def get_senna_path(self, *value):
temp = getcwd()

return join(temp, *value)

def test_pos(self):

assert isinstance(list, self.process["pos"])

0 comments on commit 9719ac9

Please sign in to comment.