UPOS string rather than int and HEAD int rather than string

#2
by lweissweiler - opened
universal-dependencies org

See title

universal-dependencies org

Hi @ellepannitto , I found the dataset class definition here:

        # Define features
        features = datasets.Features(
            {
                ...
                "lemmas": datasets.Sequence(datasets.Value("string")),
                "upos": datasets.Sequence(
                    datasets.features.ClassLabel(
                        names=[
                            "NOUN",
                            "PUNCT",
                            "ADP",
                            "NUM",
                            "SYM",
                            "SCONJ",
                            "ADJ",
                            "PART",
                            "DET",
                            "CCONJ",
                            "PROPN",
                            "PRON",
                            "X",
                            "_",
                            "ADV",
                            "INTJ",
                            "VERB",
                            "AUX",
                        ]
                    )
                ),
                "xpos": datasets.Sequence(datasets.Value("string")),
                ...

...and @lweissweiler , I think, I intended to implement something along the lines of ClassLabels (which should have int2str() and str2int():

and is advertised as a "feature" ;):

The ClassLabel feature informs 🤗 Datasets the label column contains two classes. The classes are labeled not_equivalent and equivalent. Labels are stored as integers in the dataset. When you retrieve the labels, ClassLabel.int2str() and ClassLabel.str2int() carries out the conversion from integer value to label name, and vice versa.

Overall, I'm getting the impression that the general idea of implementing this with ClassLabels is "the right" way to go about this; but something is not quite working, just yet: apparently, the ClassLabels should not be displayed as integers in the Dateset Viewer, right @christopher ?

universal-dependencies org

I would plan things on the parquet level rather than the datasets library level, and not use the ClassLabel feature at all. Parquet will compress the data just fine without it, and it would make it accessible to people loading the parquet in pandas, R, or Julia for example.

universal-dependencies org

ok, so we're back to making upos a sequence of strings; @ellepannitto if you want to look into this...

slightly misusing the discussion: for a moment, I think, there was the idea of changing the type of head, currently string and making it int? i think, the string data type comes from before mwt and empty_nodes existed, that is, "_" was a possible value and needed to be represented. is it absolutely certain that no other value than int will ever make it into head - and, considering that we would also have to go back to UD v2.7, no other value ever made it into this field?

universal-dependencies org

yes

iiegn changed discussion title from UPOS string rather than int to UPOS string rather than int and HEAD int rather than string
universal-dependencies org

great! i changed the title to reflect both type changes since, there will be overlap in code changes and tests, etc.

universal-dependencies org

Hey, sorry for the late reply.
I tried something this morning, I opened a PR here: https://github.com/bot-zen/ud-hf-parquet-tools/pull/1

I then realized I tested it with the (possibly) old metadata.json file, but the rest should be ok. @iiegn can you take a look when you have the chance? :)

universal-dependencies org

With the changes proposed in PR #1 in the helper repository https://github.com/bot-zen/ud-hf-parquet-tools and the subsequent v1.3.0 release, these changes have been implemented:

  • Store regular-token UPOS as plain strings instead of ClassLabel indices.
  • Store regular-token HEAD as int16 instead of strings.
  • Keep legacy ClassLabel UPOS reconstruction compatibility.
  • Reject invalid or out-of-range regular-token HEAD values.
  • Refresh helper documentation and release checklist.

Subsequently, this UD repository has been updated to v2.3.0 with these changes:

  • Parquet Schema

    • Regular-token upos values are now stored as strings instead of HuggingFace ClassLabel indices.
    • Regular-token head values are now stored as 16-bit integers instead of strings.
    • Empty-node head values remain strings because CoNLL-U empty nodes may use _.
    • Pinned ud-hf-parquet-tools to v1.3.0.
  • Dataset Card

    • Updated examples and links for the official Hugging Face namespace: universal-dependencies/universal_dependencies.
    • Aligned generated card metadata with the Hub-side cleanup: license: other, size_categories: 1M<n<10M, and no empty leaderboard/contact fields.
    • Added clearer citation guidance and a short note about the former commul/universal_dependencies location and the v2.0 Parquet rewrite.
  • Migration Documentation

    • Reduced old v1.x-to-v2.0 migration notes to an archived summary.
    • Added current migration notes for the upos and head schema change.

e.g., see https://huggingface.co/datasets/universal-dependencies/universal_dependencies/viewer/en_ewt/dev?views%5B%5D=en_ewt_dev&json-viewer=3 (for UPOS strings and HEAD ints).

iiegn changed discussion status to closed

Sign up or log in to comment