{"id":19437861,"url":"https://github.com/wenkokke/dep2con","last_synced_at":"2025-04-24T21:32:23.670Z","repository":{"id":20523933,"uuid":"23802944","full_name":"wenkokke/dep2con","owner":"wenkokke","description":"several algorithms for converting dependency structures into constituency structures.","archived":false,"fork":false,"pushed_at":"2022-02-07T16:25:00.000Z","size":39,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-23T09:31:36.198Z","etag":null,"topics":["constituency-tree","dependency-tree","parse-trees","tool"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"oolee/CodeFace","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wenkokke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-08T18:30:23.000Z","updated_at":"2022-08-13T16:40:54.000Z","dependencies_parsed_at":"2022-07-07T15:51:38.382Z","dependency_job_id":null,"html_url":"https://github.com/wenkokke/dep2con","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkokke%2Fdep2con","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkokke%2Fdep2con/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkokke%2Fdep2con/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkokke%2Fdep2con/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wenkokke","download_url":"https://codeload.github.com/wenkokke/dep2con/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223968120,"owners_count":17233445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["constituency-tree","dependency-tree","parse-trees","tool"],"created_at":"2024-11-10T15:16:06.764Z","updated_at":"2024-11-10T15:16:07.345Z","avatar_url":"https://github.com/wenkokke.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Conversion from dependency structures to constituency structures\n\n#### Words\n\nFirst off, the algorithm uses trees of words and part-of-speech\ntags. Part-of-speech tags are simple `String`s. Words are records with\nthree fields: a text[^1], a part of speech tag and a serial (a 1-index\ninto the sentence).\n\n\u003e data Word =\n\u003e      Word { text   :: String\n\u003e           , pos    :: String\n\u003e           , serial :: Integer\n\u003e           }\n\nWords are parsed as follows:\n\n    Word := QuotedString '/' QuotedString '/' Integer\n\nSo, for instance, they are represented as:\n\n    \"dog\"/\"NN\"/2\n\n\n#### Dependency Trees\n\nDependency trees---our input format---are represented as nodes with a\ngovernor and a list of dependants. A leaf is represented by a `Node`\nwith no dependants.\n\n\u003e data Tree =\n\u003e      Node { governor   ::  Word\n\u003e           , dependants :: [Tree]\n\u003e           }\n\nDependency trees are parsed as follows:\n\n    Node := Word | '(' Word Node* ')'\n\nSo the above word is still a valid tree, but so is the following:\n\n    (\"ROOT\"/\"ROOT\"/0\n      (\"likes\"/\"VBZ\"/4\n        (\"dog\"/\"NN\"/2 \"my\"/\"PRP\"/1)\n        (\"also\"/\"RB\"/3)\n        (\"eating\"/\"VBG\"/5 \"sausage\"/\"NN\"/6)\n      )\n    )\n\nWhich represents the following tree:\n\n```tree\n[\"ROOT\" [\"likes\" [\"dog\" \"my\"] \"also\" [\"eating\" \"sausage\"]]]\n```\n\n\n#### Constituency Trees\n\nThe main difference between constituency trees---our output\nformat---and dependency trees is that dependency trees store words at\nevery node, whereas in constituency trees only store words in the\nleaves, and the nodes are marked with part-of-speech tags.\n\n```haskell\ndata Tree\n   = Leaf Word\n   | Node POS [Tree]\n```\n\nThe printing algorithm for constituency trees is very similar to the\none for parsing dependency trees, so the following is a valid\nconstituency tree (produced by our conversion algorithm).\n\n    (\"ROOT\"\n      (\"VP\"\n        (\"NP\"\n          (\"PRP\" \"my\"/\"PRP\"/1)\n          (\"NN\" \"dog\"/\"NN\"/2)\n        )\n        (\"RB\" \"also\"/\"RB\"/3)\n        (\"VBZ\" \"likes\"/\"VBZ\"/4)\n        (\"VP\"\n          (\"VBG\" \"eating\"/\"VBG\"/5)\n          (\"NN\" \"sausage\"/\"NN\"/6)\n        )\n      )\n    )\n\nThis string represents the following tree:\n\n```tree\n[\"ROOT\" [\"VP\" [\"NP\" [\"PRP\" \"my\"] [\"NN\" \"dog\"] ] [\"RB\" \"also\"] [\"VBZ\" \"likes\"] [\"VP\" [\"VBG\" \"eating\"] [\"NN\" \"sausage\"] ] ] ]\n```\n\n\n#### Conversion à la Collins\n\nFor the conversion algorithm we use the simple algorithm as proposed\nby Collins et al., which tries to produce the simplest possible\nconstituency trees from dependency trees. The algorithm is as follows:\n\n  - if we encounter a node *without* dependencies, we simply convert it\n    into a node bearing the part-of-speech tag and a leaf bearing the\n    governor;\n\n  - if we encounter a node *with* dependencies, we do several things:\n\n      * we compute x, the part-of-speech tag of the governor;\n      * we compute xp, the phrasal projection of x (using `toXP`);\n      * we recursively apply the algorithm to the dependencies;\n      * we create a new node for x, using the current governor, and\n        insert it into the dependencies;\n      * lastly, we combine all of the above in a new node for xp.\n\nHere is the algorithm written out in Haskell:\n\n```haskell\ncollins :: Dep.Tree -\u003e Con.Tree\ncollins (Dep.Node gov [])   = Con.Node (pos gov) [Con.Leaf gov]\ncollins (Dep.Node gov deps) = Con.Node xp (insert gov' deps')\n  where\n    x     = pos gov :: POS\n    xp    = toXP x  :: POS\n    gov'  = Con.Node x [Con.Leaf gov] ::  Con.Tree\n    deps' = map collins deps          :: [Con.Tree]\n       -- ^ apply `collins` to each dependency\n```\n\n\n### References\n\nMichael Collins, Jan Hajic, Lance Ramshaw, and Christoph\nTillmann. [A Statistical Parser for Czech][^Collins1999]. Proceedings\nof ACL-1999, pages 505-512, 1999.\n\nDan Klein and Christopher D. Manning. 2003. [Accurate Unlexicalized\nParsing][^Klein2003]. Proceedings of the 41st Meeting of the\nAssociation for Computational Linguistics, pp. 423-430.\n\nRichard Socher, John Bauer, Christopher D. Manning and Andrew\nY. Ng. 2013. [Parsing With Compositional Vector Grammars][^Socher2013].\nProceedings of ACL 2013\n\nFei Xia and Martha Palmer, 2001. [Converting Dependency Structures to\nPhrase Structures][^Xia2001], Proceedings of the 1st Human Language\nTechnology Conference (HLT-2001), San Diego, Mar 18-21, 2001.\n\n[^Collins1999]: http://www.aclweb.org/anthology/P99-1065\n[^Klein2003]: http://nlp.stanford.edu/~manning/papers/unlexicalized-parsing.pdf\n[^Socher2013]: http://nlp.stanford.edu/pubs/SocherBauerManningNg_ACL2013.pdf\n[^Xia2001]: http://www.aclweb.org/anthology-new/H/H01/H01-1014.pdf\n\n[^1]: While we refer to this field as the \"text\", which is how it\n      would be used whilst using `dep2con` standalone, when we\n      integrate it with `SemAnTE` we will use it to store ids.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenkokke%2Fdep2con","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwenkokke%2Fdep2con","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenkokke%2Fdep2con/lists"}