Пример #1
0
def child_segments_data(child_slug, parent_ids):
    """

    :param child_slug: slug for the child text
    :param parent_ids: IDs of parent segments
    """
    data = defaultdict(lambda: defaultdict(list))

    # Find corresponding segments
    child = Text.query.filter(Text.slug == child_slug).one()
    results = SSA.query.filter(SSA.parent_id.in_(parent_ids))\
                       .filter(SSA.text_id==child.id).all()

    # Clean up data for display
    for r in results:
        seg = r.child
        xml_id = '.'.join((child.xmlid_prefix, seg.slug))
        content = L.transform(seg.content)
        datum = {
            'id': seg.id,
            'slug': seg.slug,
            'xmlid': xml_id,
            'content': content}
        data[r.parent_id][child_slug].append(datum)

    return data
Пример #2
0
def test_output_type(data):
    print("✨✨✨ Running test_output_type", end="")
    assert isinstance(transform(data), pd.DataFrame)
Пример #3
0
def test_output_shape(data):
    print("✨✨✨ Running test_output_shape", end="")
    assert transform(data).shape == (10, 1)
def test_output_shape():
    data = load_data("dataset_a")
    assert transform(data).shape == (10, 1)
def test_output_type():
    data = load_data("dataset_a")
    assert isinstance(transform(data), pd.DataFrame)
Пример #6
0
def test_output_type(data):
    assert isinstance(transform(data), pd.DataFrame)
Пример #7
0
def test_output_shape(data):
    assert transform(data).shape == (10, 1)
Пример #8
0
import sys
from lib import transform

logging.basicConfig(filename="cmd.log",
                    filemode="a",
                    level=logging.INFO,
                    format=LOG_FORMAT)

if len(sys.argv) < 4:
    logging.error(
        "Parameters set incorrectly, usage: cmd.py ${REQUEST_ID} ${XML_TYPE} ${XML_FILE_PATH}"
    )
    sys.exit(1)

rid = sys.argv[1]
xml_type = sys.argv[2]
path = sys.argv[3]

logging.info("{0}: Got new \"{1}\" request, file \"{2}\"".format(
    rid, xml_type, path))

f = open(path, "r", encoding="utf-8")
xml_str = f.read()
xml_str_b = xml_str.encode()
f.close()

xml_res_str = transform(xml_type, xml_str_b)

print(xml_res_str)
 def test_output_type(self):  # Uses self.widget
     print("✨✨✨ Running test_output_type")
     self.assertTrue(isinstance(transform(self.data), pd.DataFrame))
 def test_output_shape(self):  # Uses self.data
     print("✨✨✨ Running test_output_shape")
     self.assertEqual(transform(self.data).shape, (10, 1))