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

Adding Collection Rewrite to an existing collection #781

Open
margaretha opened this issue Nov 26, 2024 · 3 comments
Open

Adding Collection Rewrite to an existing collection #781

margaretha opened this issue Nov 26, 2024 · 3 comments

Comments

@margaretha
Copy link
Contributor

margaretha commented Nov 26, 2024

If a KoralQuery contains a collection property, Kustvakt adds collection/availability rewrites within the existing collection.

For corpus query corpusSigle=WPD17, Kustvakt replaces koral:doc to koral:docGroup

Before rewrite:

"collection" : {
    "@type" : "koral:doc",
    "match" : "match:eq",
    "value" : "WPD17",
    "key" : "corpusSigle"
  },
  "@context" : "http://korap.ids-mannheim.de/ns/koral/0.3/context.jsonld"

After rewrite:

{
  "@context": "http://korap.ids-mannheim.de/ns/KoralQuery/v0.3/context.jsonld",
  "collection": {
    "@type": "koral:docGroup",
    "operands": [
      {
        "@type": "koral:doc",
        "key": "availability",
        "match": "match:eq",
        "type": "type:regex",
        "value": "CC.*"
      },
      {
        "@type": "koral:doc",
        "key": "corpusSigle",
        "match": "match:eq",
        "value": "WPD17",
        "type": "type:string"
      }
    ],
    "operation": "operation:and",
    "rewrites": [
      {
        "@type": "koral:rewrite",
        "operation": "operation:insertion",
        "scope": "availability(FREE)",
        "src": "Kustvakt"
      }
    ]
  },

Theoretically the rewrites should be placed at the same level at collection with operation:override instead.

Suggestion 1

{
  "@context": "http://korap.ids-mannheim.de/ns/KoralQuery/v0.3/context.jsonld",
  "collection": {
    "@type": "koral:docGroup",
    "operands": [
      {
        "@type": "koral:doc",
        "key": "availability",
        "match": "match:eq",
        "type": "type:regex",
        "value": "CC.*"
      },
      {
        "@type": "koral:doc",
        "key": "corpusSigle",
        "match": "match:eq",
        "value": "WPD17",
        "type": "type:string"
      }
    ],
    "operation": "operation:and"
  },
  "rewrites": [
    {
      "@type": "koral:rewrite",
      "operation": "operation:override",
      "scope": "collection",
      "src": "Kustvakt",
      "origin": "Kustvakt",
      "source" : 
        {
          "@type" : "koral:doc",
          "match" : "match:eq",
          "value" : "WPD17",
          "key" : "corpusSigle"
       }
    }
  ]

Alternatively, the rewrites can be placed within collection and it should include deletions as follows. But it is rather verbose.

Suggestion 2

{
  "@context": "http://korap.ids-mannheim.de/ns/KoralQuery/v0.3/context.jsonld",
  "collection": {
    "@type": "koral:docGroup",
    "operands": [
      {
        "@type": "koral:doc",
        "key": "availability",
        "match": "match:eq",
        "type": "type:regex",
        "value": "CC.*"
      },
      {
        "@type": "koral:doc",
        "key": "corpusSigle",
        "match": "match:eq",
        "value": "WPD17",
        "type": "type:string"
      }
    ],
    "operation": "operation:and",
    "rewrites": [
      {
        "@type": "koral:rewrite",
        "operation": "operation:injection",
        "src": "Kustvakt"
        "origin": "Kustvakt"
      },
      {
        "@type" : "koral:rewrite",
        "src" : "Kustvakt",
        "origin" : "Kustvakt",
        "operation" : "operation:deletion",
        "scope" : "@type",
        "source" : "koral:doc"
      },
      {
        "@type" : "koral:rewrite",
        "src" : "Kustvakt",
        "origin" : "Kustvakt",
        "operation" : "operation:deletion",
        "scope" : "match",
        "source" : "match:eq"
      },
      {
        "@type" : "koral:rewrite",
        "src" : "Kustvakt",
        "origin" : "Kustvakt",
        "operation" : "operation:deletion",
        "scope" : "value",
        "source" : "WPD17"
      },
      {
        "@type" : "koral:rewrite",
        "src" : "Kustvakt",
        "origin" : "Kustvakt",
        "operation" : "operation:deletion",
        "scope" : "key",
        "source" : "corpusSigle"
      }
    ]
  }
}

See also #782

@Akron
Copy link
Member

Akron commented Nov 28, 2024

I think the first version is better, although the parsing/marking is a bit more complicated. But adding a rewrite to the next higher unchanged element seems to be reasonable.

@margaretha
Copy link
Contributor Author

Adding the rewrite at one level higher turns out to be more complicated when there are multiple rewrites and a rewrite is done on top of a rewritten node, see #780 .

@margaretha
Copy link
Contributor Author

The 2nd option can be simplified as follows:

{
    "@context": "http://korap.ids-mannheim.de/ns/KoralQuery/v0.3/context.jsonld",
    "collection": {
        "@type": "koral:docGroup",
        "operands": [
            {
                "@type": "koral:doc",
                "key": "availability",
                "match": "match:eq",
                "type": "type:regex",
                "value": "CC.*"
            },
            {
                "@type": "koral:doc",
                "key": "corpusSigle",
                "match": "match:eq",
                "value": "WPD17",
                "type": "type:string"
            }
        ],
        "operation": "operation:and",
        "rewrites": [
            {
                "@type": "koral:rewrite",
                "operation": "operation:override",
                "src": "Kustvakt",
                "origin": "Kustvakt",
                "source": {
                    "@type": "koral:doc",
                    "match": "match:eq",
                    "value": "WPD17",
                    "key": "corpusSigle"
                }
            }
        ]
    }
}

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

No branches or pull requests

2 participants