Skip to content

Commit

Permalink
Fixed bugs #125
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Jun 24, 2021
1 parent b8faeba commit 5ccb8bd
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 13 deletions.
2 changes: 2 additions & 0 deletions common/entities/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class Entity(object):

def __init__(self, value, e_type, id_in_doc, group_index=None):
assert(isinstance(value, unicode) and len(value) > 0)
if not isinstance(e_type, unicode):
print e_type
assert(isinstance(e_type, unicode))
assert(isinstance(group_index, int) or group_index is None)
self.__value = value.lower()
Expand Down
Empty file added tests/contrib/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion tests/contrib/bert/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from arekit.common.experiment.input.providers.row_ids.multiple import MultipleIDProvider
from arekit.common.experiment.input.readers.sample import InputSampleReader
from arekit.contrib.bert.output.google_bert import GoogleBertMulticlassOutput
from arekit.contrib.bert.test.labels import TestThreeLabelScaler
from arekit.tests.contrib.bert.labels import TestThreeLabelScaler


class TestOutputFormatters(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from arekit.tests.text.utils import terms_to_str
from arekit.tests.text.linked_opinions import iter_same_sentence_linked_text_opinions

from arekit.tests.contrib.source.text.news import init_rusentrel_doc
from arekit.contrib.source.rusentiframes.collection import RuSentiFramesCollection
from arekit.contrib.source.rusentiframes.types import RuSentiFramesVersions
from arekit.contrib.source.tests.text.news import init_rusentrel_doc
from arekit.contrib.experiment_rusentrel.frame_variants import ExperimentFrameVariantsCollection
from arekit.contrib.experiment_rusentrel.synonyms.provider import RuSentRelSynonymsCollectionProvider
from arekit.contrib.experiment_rusentrel.labels.formatters.rusentiframes import \
Expand Down
3 changes: 2 additions & 1 deletion tests/contrib/networks/test_samples_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
from arekit.common.experiment import const
from arekit.contrib.networks.core.input.rows_parser import ParsedSampleRow
from arekit.contrib.networks.context.configurations.base.base import DefaultNetworkConfig
from arekit.contrib.networks.tests.labels import TestThreeLabelScaler
from arekit.contrib.networks.sample import InputSample

from arekit.tests.contrib.networks.labels import TestThreeLabelScaler


class TestSamplesIteration(unittest.TestCase):

Expand Down
5 changes: 3 additions & 2 deletions tests/contrib/networks/test_tf_ctx_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
sys.path.append('../../../')

from arekit.common.languages.ru.pos_service import PartOfSpeechTypesService
from arekit.contrib.networks.tests.tf_networks.utils import init_config
from arekit.contrib.networks.tests.tf_networks.supported import get_supported
from arekit.contrib.networks.context.configurations.base.base import DefaultNetworkConfig

from arekit.tests.contrib.networks.tf_networks.supported import get_supported
from arekit.tests.contrib.networks.tf_networks.utils import init_config


class TestContextNetworkCompilation(unittest.TestCase):

Expand Down
5 changes: 3 additions & 2 deletions tests/contrib/networks/test_tf_ctx_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

from arekit.contrib.networks.context.configurations.base.base import DefaultNetworkConfig
from arekit.contrib.networks.sample import InputSample
from arekit.contrib.networks.tests.tf_networks.supported import get_supported
from arekit.contrib.networks.tests.tf_networks.utils import init_config
from arekit.contrib.networks.core.feeding.bags.bag import Bag
from arekit.contrib.networks.core.feeding.batch.base import MiniBatch
from arekit.contrib.networks.core.nn import NeuralNetwork

from arekit.tests.contrib.networks.tf_networks.supported import get_supported
from arekit.tests.contrib.networks.tf_networks.utils import init_config


class TestContextNetworkFeeding(unittest.TestCase):

Expand Down
2 changes: 1 addition & 1 deletion tests/contrib/networks/test_tf_input_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from arekit.processing.lemmatization.mystem import MystemWrapper
from arekit.processing.pos.mystem_wrap import POSMystemWrapper

from arekit.contrib.networks.tests.text.news import init_rusentrel_doc
from arekit.tests.contrib.networks.text.news import init_rusentrel_doc
from arekit.contrib.networks.features.term_indices import IndicesFeature

from arekit.tests.text.linked_opinions import iter_same_sentence_linked_text_opinions
Expand Down
5 changes: 3 additions & 2 deletions tests/contrib/networks/test_tf_mi_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import sys
import unittest


sys.path.append('../../../')

from arekit.contrib.networks.tests.tf_networks.supported import get_supported
from arekit.contrib.networks.tests.tf_networks.utils import init_config
from arekit.tests.contrib.networks.tf_networks.utils import init_config
from arekit.tests.contrib.networks.tf_networks.supported import get_supported
from arekit.contrib.networks.context.configurations.base.base import DefaultNetworkConfig
from arekit.contrib.networks.multi.architectures.max_pooling import MaxPoolingOverSentences
from arekit.contrib.networks.multi.configurations.base import BaseMultiInstanceConfig
Expand Down
5 changes: 3 additions & 2 deletions tests/contrib/networks/test_tf_mi_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
from arekit.common.labels.base import NoLabel
from arekit.common.labels.scaler import BaseLabelScaler

from arekit.contrib.networks.tests.tf_networks.supported import get_supported
from arekit.contrib.networks.core.feeding.bags.bag import Bag
from arekit.contrib.networks.core.feeding.batch.multi import MultiInstanceMiniBatch

from arekit.contrib.networks.multi.configurations.max_pooling import MaxPoolingOverSentencesConfig
from arekit.contrib.networks.context.configurations.base.base import DefaultNetworkConfig
from arekit.contrib.networks.sample import InputSample
from arekit.contrib.networks.multi.architectures.max_pooling import MaxPoolingOverSentences
from arekit.contrib.networks.tests.test_tf_ctx_feed import TestContextNetworkFeeding

from arekit.tests.contrib.networks.test_tf_ctx_feed import TestContextNetworkFeeding
from arekit.tests.contrib.networks.tf_networks.supported import get_supported


class TestMultiInstanceFeed(unittest.TestCase):
Expand Down
14 changes: 13 additions & 1 deletion tests/contrib/source/test_ruattitudes.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,23 @@ def __test_iter_news_inds(self, ra_version):

print u"Total documents count: {}".format(max(it))

def __test_reading(self, ra_version):
def __test_reading(self, ra_version, do_printing=True):

# iterating through collection
news_read = 0
news_it = RuAttitudesCollection.iter_news(version=ra_version,
get_news_index_func=lambda _: news_read,
return_inds_only=False)

if not do_printing:
news_it = tqdm(news_it)

for news in news_it:
assert(isinstance(news, RuAttitudesNews))

if not do_printing:
continue

logger.debug(u"News: {}".format(news.ID))

for sentence in news.iter_sentences(return_text=False):
Expand Down Expand Up @@ -169,6 +176,11 @@ def test_iter_news_inds(self):
def test_reading(self):
self.__test_reading(ra_version=self.__ra_versions[2])

def test_quick_reading_of_all_version(self):
for version in self.__ra_versions:
print "Testing version: {version}".format(version=version)
self.__test_reading(ra_version=version, do_printing=False)


if __name__ == '__main__':
unittest.main()

0 comments on commit 5ccb8bd

Please sign in to comment.