Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_paired_list(self):
self.assertEqual(
parse_paired_list_value("4:nsubj"),
[("nsubj", 4)]
)
self.assertEqual(
parse_paired_list_value("1:under_case_:under_case_|2:dash-sign-:dash-sign-"),
[("under_case_:under_case_", 1), ("dash-sign-:dash-sign-", 2)]
)
self.assertEqual(
parse_paired_list_value("2:nsubj|4:nsubj"),
[("nsubj", 2), ("nsubj", 4)]
)
self.assertEqual(
parse_paired_list_value("1:flat:name|2:amod|20:nsubj"),
[("flat:name", 1), ("amod", 2), ("nsubj", 20)]
)
self.assertEqual(
parse_paired_list_value("5:conj:and|8.1:nsubj:pass|9:nsubj:xsubj"),
[("conj:and", 5), ("nsubj:pass", (8, ".", 1)), ("nsubj:xsubj", 9)]
)
self.assertEqual(
parse_paired_list_value("1:compound|6:ARG|9:ARG1|10:ARG2"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('ARG2', 10)]
)
self.assertNotEqual(
parse_paired_list_value("1:compound|6:ARG|9:ARG1|10:2ARG"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('2ARG', 10)]
)
self.assertEqual(
parse_paired_list_value("0:root"),
[("flat:name", 1), ("amod", 2), ("nsubj", 20)]
)
self.assertEqual(
parse_paired_list_value("5:conj:and|8.1:nsubj:pass|9:nsubj:xsubj"),
[("conj:and", 5), ("nsubj:pass", (8, ".", 1)), ("nsubj:xsubj", 9)]
)
self.assertEqual(
parse_paired_list_value("1:compound|6:ARG|9:ARG1|10:ARG2"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('ARG2', 10)]
)
self.assertNotEqual(
parse_paired_list_value("1:compound|6:ARG|9:ARG1|10:2ARG"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('2ARG', 10)]
)
self.assertEqual(
parse_paired_list_value("0:root"),
[('root', 0)]
)
self.assertEqual(
parse_paired_list_value("1:obl:arg:gen"),
[('obl:arg:gen', 1)]
)
self.assertEqual(
parse_paired_list_value("25:obl:arg:į"),
[('obl:arg:į', 25)]
)
self.assertEqual(
parse_paired_list_value("3:obl:arg:عَلَى:gen"),
[('obl:arg:عَلَى:gen', 3)]
)
[("conj:and", 5), ("nsubj:pass", (8, ".", 1)), ("nsubj:xsubj", 9)]
)
self.assertEqual(
parse_paired_list_value("1:compound|6:ARG|9:ARG1|10:ARG2"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('ARG2', 10)]
)
self.assertNotEqual(
parse_paired_list_value("1:compound|6:ARG|9:ARG1|10:2ARG"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('2ARG', 10)]
)
self.assertEqual(
parse_paired_list_value("0:root"),
[('root', 0)]
)
self.assertEqual(
parse_paired_list_value("1:obl:arg:gen"),
[('obl:arg:gen', 1)]
)
self.assertEqual(
parse_paired_list_value("25:obl:arg:į"),
[('obl:arg:į', 25)]
)
self.assertEqual(
parse_paired_list_value("3:obl:arg:عَلَى:gen"),
[('obl:arg:عَلَى:gen', 3)]
)
[("under_case_:under_case_", 1), ("dash-sign-:dash-sign-", 2)]
)
self.assertEqual(
parse_paired_list_value("2:nsubj|4:nsubj"),
[("nsubj", 2), ("nsubj", 4)]
)
self.assertEqual(
parse_paired_list_value("1:flat:name|2:amod|20:nsubj"),
[("flat:name", 1), ("amod", 2), ("nsubj", 20)]
)
self.assertEqual(
parse_paired_list_value("5:conj:and|8.1:nsubj:pass|9:nsubj:xsubj"),
[("conj:and", 5), ("nsubj:pass", (8, ".", 1)), ("nsubj:xsubj", 9)]
)
self.assertEqual(
parse_paired_list_value("1:compound|6:ARG|9:ARG1|10:ARG2"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('ARG2', 10)]
)
self.assertNotEqual(
parse_paired_list_value("1:compound|6:ARG|9:ARG1|10:2ARG"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('2ARG', 10)]
)
self.assertEqual(
parse_paired_list_value("0:root"),
[('root', 0)]
)
self.assertEqual(
parse_paired_list_value("1:obl:arg:gen"),
[('obl:arg:gen', 1)]
)
self.assertEqual(
parse_paired_list_value("25:obl:arg:į"),
[("nsubj", 2), ("nsubj", 4)]
)
self.assertEqual(
parse_paired_list_value("1:flat:name|2:amod|20:nsubj"),
[("flat:name", 1), ("amod", 2), ("nsubj", 20)]
)
self.assertEqual(
parse_paired_list_value("5:conj:and|8.1:nsubj:pass|9:nsubj:xsubj"),
[("conj:and", 5), ("nsubj:pass", (8, ".", 1)), ("nsubj:xsubj", 9)]
)
self.assertEqual(
parse_paired_list_value("1:compound|6:ARG|9:ARG1|10:ARG2"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('ARG2', 10)]
)
self.assertNotEqual(
parse_paired_list_value("1:compound|6:ARG|9:ARG1|10:2ARG"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('2ARG', 10)]
)
self.assertEqual(
parse_paired_list_value("0:root"),
[('root', 0)]
)
self.assertEqual(
parse_paired_list_value("1:obl:arg:gen"),
[('obl:arg:gen', 1)]
)
self.assertEqual(
parse_paired_list_value("25:obl:arg:į"),
[('obl:arg:į', 25)]
)
self.assertEqual(
parse_paired_list_value("3:obl:arg:عَلَى:gen"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('ARG2', 10)]
)
self.assertNotEqual(
parse_paired_list_value("1:compound|6:ARG|9:ARG1|10:2ARG"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('2ARG', 10)]
)
self.assertEqual(
parse_paired_list_value("0:root"),
[('root', 0)]
)
self.assertEqual(
parse_paired_list_value("1:obl:arg:gen"),
[('obl:arg:gen', 1)]
)
self.assertEqual(
parse_paired_list_value("25:obl:arg:į"),
[('obl:arg:į', 25)]
)
self.assertEqual(
parse_paired_list_value("3:obl:arg:عَلَى:gen"),
[('obl:arg:عَلَى:gen', 3)]
)
def test_parse_invalid(self):
testcases = [
"x:nsubj",
"0:",
"0:_",
"0:-",
":",
":nsubj",
"1:nsubj|",
"1:nsubj||1:nsubj",
]
for testcase in testcases:
# Invalid strings should be returned untouched
self.assertEqual(parse_paired_list_value(testcase), testcase)
def test_parse_paired_list(self):
self.assertEqual(
parse_paired_list_value("4:nsubj"),
[("nsubj", 4)]
)
self.assertEqual(
parse_paired_list_value("1:under_case_:under_case_|2:dash-sign-:dash-sign-"),
[("under_case_:under_case_", 1), ("dash-sign-:dash-sign-", 2)]
)
self.assertEqual(
parse_paired_list_value("2:nsubj|4:nsubj"),
[("nsubj", 2), ("nsubj", 4)]
)
self.assertEqual(
parse_paired_list_value("1:flat:name|2:amod|20:nsubj"),
[("flat:name", 1), ("amod", 2), ("nsubj", 20)]
)
self.assertEqual(
parse_paired_list_value("5:conj:and|8.1:nsubj:pass|9:nsubj:xsubj"),
[('compound', 1), ('ARG', 6), ('ARG1', 9), ('2ARG', 10)]
)
self.assertEqual(
parse_paired_list_value("0:root"),
[('root', 0)]
)
self.assertEqual(
parse_paired_list_value("1:obl:arg:gen"),
[('obl:arg:gen', 1)]
)
self.assertEqual(
parse_paired_list_value("25:obl:arg:į"),
[('obl:arg:į', 25)]
)
self.assertEqual(
parse_paired_list_value("3:obl:arg:عَلَى:gen"),
[('obl:arg:عَلَى:gen', 3)]
)
def test_parse_empty(self):
testcases = [
"",
"_",
]
for testcase in testcases:
# Empty strings should return None
self.assertEqual(parse_paired_list_value(testcase), None)