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

Allow CiteRef annotations within #ask query results #40

Closed
dm-mitre opened this issue Mar 8, 2017 · 4 comments
Closed

Allow CiteRef annotations within #ask query results #40

dm-mitre opened this issue Mar 8, 2017 · 4 comments

Comments

@dm-mitre
Copy link

dm-mitre commented Mar 8, 2017

Setup and configuration

  • SMW version: 2.4.0
  • SCI version: 1.2.0
  • MW version: 1.29.0-wmf.8
  • DB: MySQL 5.7.17

Issue

In versions of SMW before 2.4.0 [[CiteRef::...]] annotations worked when retrieved through an ask query, that is a CiteRef annotation could be stored within a text property and when displayed with an ask query the citation would be properly generated. In 2.4.0+, ask queries whose results contain a CiteRef annotation just print out the key and not a citation.

I believe this is related to SemanticMediaWiki/SemanticMediaWiki#1314

@mwjames
Copy link
Contributor

mwjames commented Mar 8, 2017 via email

@dm-mitre
Copy link
Author

dm-mitre commented Mar 9, 2017

Example here: https://sandbox.semantic-mediawiki.org/wiki/Semantic_Cite_Annotation_Within_Ask

Note how the key is echoed in the ask query result.

@mwjames
Copy link
Contributor

mwjames commented Mar 11, 2017

Example here: https://sandbox.semantic-mediawiki.org/wiki/Semantic_Cite_Annotation_Within_Ask

👍

In versions of SMW before 2.4.0 [[CiteRef::...]] annotations worked when retrieved through an ask query, that is a CiteRef annotation could be stored within a text property and when displayed with an ask query the citation would be properly generated. In 2.4.0+, ask queries whose results contain a CiteRef annotation just print out the key and not a citation.

I wasn't aware of users relying on such behaviour and since it can be a legitimate use case, I added a small change SemanticMediaWiki/SemanticMediaWiki/pull/2325 to SMW-core to allow for such scenarios to be supported without requiring a special handling in this extension.

I believe this is related to SemanticMediaWiki/SemanticMediaWiki#1314

#1320 and #1324 are to avoid that in-text annotations are imported into pages that are not expected to be associated with an entity (those that are stored in raw form like [[[ :: ]]]) but in order to enable above cited scenario, #-ia (import annotation) is added as output formatter to allow to retain those and give the parser an opportunity to reparse embedded value annotations. Your example would require a small change as in:

{{#ask:[[{{FULLPAGENAME}}]]
 |?Has description
 |?Has description#-ia
 |mainlabel=-
 |link=none
 |headers=hide
 |format=ul
}}

Notes

@kghbln FYI

I will note the difference in processing for #set and the in-text annotation (with an enabled SMW_LINV_OBFU).

#set

When using #set as in the example above then the text that gets stored with the property (Has description) will contain the unprocessed [[CiteRef::reptile-database-gilberti]] content.

{{#set:
 |Has description=Mid coast WA to QLD[[CiteRef::reptile-database-gilberti]]
 |template=SetParserForValueInclusion
}}

The #ask fetches the text (using #-ia) for display and will process [[CiteRef::reptile-database-gilberti]] as extra annotation by the time the raw string runs through the parser, creating an additional Citation reference annotation for the entity that embeds the #ask query.

[[ ... :: ... ]]

When instead of the #set parser function the in-text notation is used as in [[Has description::Mid coast WA to QLD[[CiteRef::reptile-database-gilberti]]]] then the results are different because the InTextAnnotation parser has to directly process the text and all its components to ensure a sanitized string is returned to the original MediaWiki parser.

This results the Has description property will store is a resolved CiteRef annotation and not the raw form of [[CiteRef::reptile-database-gilberti]]. The stored from would be something similar to Mid coast WA to QLD <span id="scite-ref-f803f82beb9b1796121b4ab5085e0543-1-a" class="scite-citeref-number" data-reference=":reptile-database-gilberti">[[#scite-f803f82beb9b1796121b4ab5085e0543|1]]</span>.

The difference in processing is due to a how and when string processing appears and needs to be returned to an output instance. For #set this happens isolated as a separate parse process encapsulated from any other text processing while [[ ... :: ... ]] is part of an on-going text manipulation which requires the instance to return a visible result as part of this process.

@mwjames
Copy link
Contributor

mwjames commented Mar 11, 2017

The cited example works as expected after SemanticMediaWiki/SemanticMediaWiki#2325 but it requires 2.5.0 to work with.

@mwjames mwjames closed this as completed Mar 11, 2017
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