Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing of CoNLL comments into CoNLL-RDF + CoNLL-U Plus Support #17

Merged
merged 19 commits into from
Oct 29, 2019

Conversation

glaserL
Copy link
Collaborator

@glaserL glaserL commented Oct 23, 2019

Arbitrary CoNLL comments

This implements metadata support for CoNLL when transforming to CoNLL-RDF. All comments in the CoNLL format that are lead by a hashmark will be written to the rdf graph as a rdfs:comment property of the sentence head node.

For example, this:

# this is a comment
1       This
2       is
3       a
4       sentence
5       .

will result in this CoNLL-RDF:

# this is a comment
@prefix :      <https://example.com/> .
@prefix powla: <http://purl.org/powla/powla.owl#> .
@prefix terms: <http://purl.org/acoli/open-ie/> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix conll: <http://ufal.mff.cuni.cz/conll2009-st/task-description.html#> .
@prefix x:     <http://purl.org/acoli/conll-rdf/xml#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix nif:   <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .

:s1_1   a             nif:Word ;
        nif:nextWord  :s1_2 ;
        conll:HEAD    :s1_0 ;
        conll:ID      "1" ;
        conll:WORD    "This" .

:s1_4   a             nif:Word ;
        nif:nextWord  :s1_5 ;
        conll:HEAD    :s1_0 ;
        conll:ID      "4" ;
        conll:WORD    "sentence" .

:s1_2   a             nif:Word ;
        nif:nextWord  :s1_3 ;
        conll:HEAD    :s1_0 ;
        conll:ID      "2" ;
        conll:WORD    "is" .

:s1_0   a             nif:Sentence ;
        rdfs:comment  " this is a comment" .

:s1_5   a           nif:Word ;
        conll:HEAD  :s1_0 ;
        conll:ID    "5" ;
        conll:WORD  "." .

:s1_3   a             nif:Word ;
        nif:nextWord  :s1_4 ;
        conll:HEAD    :s1_0 ;
        conll:ID      "3" ;
        conll:WORD    "a" .

Also note, that we still directly transport any hashmark-lead comments to the CoNLL-RDF for backwards compartability. Also, when exporting CoNLL with the CoNLLRDFFormatter, we will write a global.columns comment to the first line of each sentence to improve ease of handling when reusing the CoNLLStreamExtractor, see below.

CoNLL-U Plus support

In addition to the general metadata support, we now support automatic column setting with the new CoNLL-U Plus Format

If the user does not supply any column names when calling the CoNLLStreamExtractor, we will try to find a global.columns comment in ONLY the first line and, if present, will use this as column names. Also, if using the CoNLLRDFFormatter to write conll again, we will search both raw conll comments and the rdfs:comment property for such a global.columns comment, IF the user did not provide column names themselves. They overwrite each other with following priority: -conll ARGS > rdfs:comment > raw conll comment.

@glaserL glaserL requested a review from cfaeth October 23, 2019 15:33
@glaserL
Copy link
Collaborator Author

glaserL commented Oct 23, 2019

This roughly refers to acoli-repo/conll#1

@cfaeth
Copy link
Collaborator

cfaeth commented Oct 29, 2019

Tested with existing pipelines. Handling of comments does not seem to interfere with other functionalities.

@cfaeth cfaeth merged commit b67c7d3 into acoli-repo:master Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants