SemanticMediaWiki / SemanticCite

Allows to manage citation resources using semantic annotations
https://www.semantic-mediawiki.org/wiki/Extension:Semantic_Cite
Other
24 stars 13 forks source link

Allow CiteRef annotations within #ask query results #40

Closed dm-mitre closed 7 years ago

dm-mitre commented 7 years ago

Setup and configuration

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 https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/1314

mwjames commented 7 years ago

Hi,

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'm a bit unsure about the context, could you design an example on the sandbox as to what is queried and what is expected.

Cheers

On 3/9/17, dm-mitre notifications@github.com wrote:

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 https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/1314

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/SemanticMediaWiki/SemanticCite/issues/40

dm-mitre commented 7 years ago

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 commented 7 years ago

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

:+1:

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 commented 7 years ago

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