diff --git a/etk/core.py b/etk/core.py index 4e5147cb..345ba2f3 100644 --- a/etk/core.py +++ b/etk/core.py @@ -2021,11 +2021,11 @@ def parse_number(d, config=None): return None if isinstance(text, numbers.Number): - return float(text) + return str(text) try: text = text.strip().replace('\n', '').replace('\t', '') - num = float(text) + num = str(float(text)) if '.' in text else str(int(text)) return num except: pass diff --git a/etk/unit_tests/test_content_extractions.py b/etk/unit_tests/test_content_extractions.py index cca040c2..afdc04fa 100644 --- a/etk/unit_tests/test_content_extractions.py +++ b/etk/unit_tests/test_content_extractions.py @@ -499,7 +499,12 @@ def test_extract_as_is_post_filter_3(self): { "description": "Noncombatant Status Asserted", "id": "assertedcontestednoncombatantnoncombatantnotstatusstatus", - "size": "red34" + "size": "34.0" + }, + { + "description": "Noncombatant Status Asserted", + "id": "assertedcontestednoncombatantnoncombatantnotstatusstatus", + "size": "redme34" } ] } @@ -539,7 +544,9 @@ def test_extract_as_is_post_filter_3(self): } c = Core(extraction_config=e_config) r = c.process(doc) - self.assertEqual(r['knowledge_graph']['actor_size'][0]['value'], 54.0) + self.assertTrue(len(r['knowledge_graph']['actor_size']) == 2) + self.assertEqual(r['knowledge_graph']['actor_size'][0]['value'], '54') + self.assertEqual(r['knowledge_graph']['actor_size'][1]['value'], '34.0') def test_extract_as_is_artbitrary_path(self): doc = {