How to use the conllu.parser.parse_paired_list_value function in conllu

To help you get started, we’ve selected a few conllu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EmilStenstrom / conllu / tests / test_parser.py View on Github external
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"),
github EmilStenstrom / conllu / tests / test_parser.py View on Github external
[("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)]
        )
github EmilStenstrom / conllu / tests / test_parser.py View on Github external
[("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)]
        )
github EmilStenstrom / conllu / tests / test_parser.py View on Github external
[("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:į"),
github EmilStenstrom / conllu / tests / test_parser.py View on Github external
[("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"),
github EmilStenstrom / conllu / tests / test_parser.py View on Github external
[('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)]
        )
github EmilStenstrom / conllu / tests / test_parser.py View on Github external
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)
github EmilStenstrom / conllu / tests / test_parser.py View on Github external
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"),
github EmilStenstrom / conllu / tests / test_parser.py View on Github external
[('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)]
        )
github EmilStenstrom / conllu / tests / test_parser.py View on Github external
def test_parse_empty(self):
        testcases = [
            "",
            "_",
        ]
        for testcase in testcases:
            # Empty strings should return None
            self.assertEqual(parse_paired_list_value(testcase), None)