Difference between revisions of "Sample Queries"

 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
These queries illustrate the power of the [https://www.semantic-mediawiki.org/wiki/Help:Semantic_search Semantic MediaWiki query language] ("semantic search") and the Semantic MediaWiki query interfaces to extract data stored by the FNA Semantic MediaWiki.
+
These queries illustrate the power of the [https://www.semantic-mediawiki.org/wiki/Help:Semantic_search Semantic MediaWiki query language] ("semantic search") and the Semantic MediaWiki query interfaces to extract data stored by the Flora of North America Semantic MediaWiki.
 +
 
 +
[[Special:Ask|Click here to access the '''Semantic search query interface''' directly.]]
  
 
== Queries by Subject ==
 
== Queries by Subject ==
Line 163: Line 165:
 
[https://github.com/jocelynpender/fna-query/blob/master/python/demo_queries/publication_details/taxa_by_publication_year.py Python script]
 
[https://github.com/jocelynpender/fna-query/blob/master/python/demo_queries/publication_details/taxa_by_publication_year.py Python script]
 
|}
 
|}
You can use [https://www.semantic-mediawiki.org/wiki/Help:Search_operators comparators] with the [[Property:Publication year|Publication year property]]! For example,
+
You can use [https://www.semantic-mediawiki.org/wiki/Help:Search_operators comparators] with the [[Property:Publication year|Publication year property]]. For example,
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 384: Line 386:
 
|<code><nowiki>[[Publication year::<<1754]]</nowiki><nowiki>[[Taxon family::Cyperaceae]]</nowiki></code>
 
|<code><nowiki>[[Publication year::<<1754]]</nowiki><nowiki>[[Taxon family::Cyperaceae]]</nowiki></code>
 
|}
 
|}
 +
 +
=== Comparators ===
 +
You can use [https://www.semantic-mediawiki.org/wiki/Help:Search_operators comparators] with the [[Property:Publication year|Publication year property]]. (e.g., '''<code>></code>''', '''<code><</code>''', '''<code>≥</code>''').
  
 
=== Return More Information ===
 
=== Return More Information ===
You can return any properties you wish with the optional |'''? parameter''':
+
You can return as many additional properties as you wish:
 +
{| class="wikitable"
 +
![[Special:Ask|Query interface]]
 +
![https://github.com/jocelynpender/fna-query Query the API]
 +
|-
 +
|Add property names to the '''Additional data to display box'''
 +
| <nowiki>Add property names using the '''|?''' syntax:
 +
<code><nowiki>[[Authority::Linnaeus]]</nowiki><nowiki>[[Distribution::Nunavut]]</nowiki> |Add properties using '''<nowiki>the |? syntax:</nowiki>'''
 +
<code><nowiki>[[Authority::Linnaeus]]</nowiki><nowiki>[[Distribution::Nunavut]]</nowiki>|?Taxon family|?Taxon rank|?Author</code>
 +
|}
 +
 
 +
== Write Your Own Queries ==
 +
[[Special:Ask|Click here to access the '''Semantic search query interface''' directly.]]
 +
 
 +
Note that:
 +
* The '''limit''' on the number of results returned '''can be changed'''
 +
* You can only export '''what is displayed on the page''' (JSON, CSV, RSS, RDF)
 +
** Page through the results to download each batch
 +
 
 +
=== Why use the API convenience scripts? ===
 +
# For big queries, it may be cumbersome to download each batch of 500 results separately and then merge the results.
 +
# If you are performing your analyses in R or Python, you may wish to embed the data extraction here, so that it can be easily re-run.
  
<code><nowiki>[[Authority::Linnaeus]]</nowiki><nowiki>[[Distribution::Nunavut]]</nowiki>|?Taxon family|?Author</code>
+
Access the convenience scripts here: https://github.com/jocelynpender/fna-query
  
 
== Query Resources ==
 
== Query Resources ==

Latest revision as of 15:52, 13 February 2020

These queries illustrate the power of the Semantic MediaWiki query language ("semantic search") and the Semantic MediaWiki query interfaces to extract data stored by the Flora of North America Semantic MediaWiki.

Click here to access the Semantic search query interface directly.

Queries by Subject

Taxonomy

Properties Used Query Syntax Query Interface Query Results Query the API
All Taxa in the Online FNA Taxon rank (see allowed values) [[Taxon rank::+]] Try it! R script

Python script

All Species in the Online FNA Taxon rank (see allowed values) [[Taxon rank::species]] Try it! R script

Python script

List of Lower Taxa Taxon parent [[Taxon parent::Carex]] Try it! In the genus Carex, R script

Python script

List of Sections Taxon family (see allowed values)

Taxon rank (see allowed values)

[[Taxon family::Asteraceae]][[Taxon rank::section]] Try it! Sections in the family Asteraceae, R script

Python script

Distribution

Properties Used Query Syntax Query Interface Query Results Query the API
Taxa occurring in Non-Abbreviated State or Province (i.e., Alaska, Idaho, Iowa, Maine, Nunavut, Ohio, Yukon) Distribution (see allowed values and Distribution Abbreviations) [[Distribution::Nunavut]] Try it! Taxa occurring in Nunavut, R script

Python script

Taxa occurring in Abbreviated State or Province Distribution (see allowed values and Distribution Abbreviations) [[Distribution::Ont.]] Try it! Taxa occurring in Ontario, R script

Python script

Publication Details

Properties Used Query Syntax Query Interface Query Results Query the API
Taxa by Authority Authority [[Authority::Linnaeus]] Try it! Taxa described by Linnaeus, R script

Python script

Taxa by Publication Title Publication title [[Publication title::Proc. Amer. Acad. Arts]] Try it! R script

Python script

Taxa by Publication Year Publication year [[Publication year::1990]] Try it! R script

Python script

You can use comparators with the Publication year property. For example,

Taxa by Publication Year with Comparator Publication year [[Publication year::>>1990]] Try it! Taxa published after 1990, R script

Python script

Special Status

Due to limitations in data capture, special status data are only available in V3, V6, V9, V12, V17, V28.

Properties Used Query Syntax Query Interface Query Results Query the API
Taxa by Special Status Special status (see allowed values) [[Special status::Introduced]] Try it! Introduced species, R script

Python script

Illustrations

Properties Used Query Syntax Query Interface Query Results Query the API
All Illustrated Taxa in the Online FNA Illustrator (see allowed values)

Illustration

[[Illustrator::+]][[Illustration::Present]] Try it! R script

Python script

List of Illustrations by Person Illustrator (see allowed values)

Illustration

[[Illustrator::Annaliese Miller]][[Illustration::Present]] Try it! Illustrations by Annaliese Miller, R script

Python script

Volumes

Properties Used Query Syntax Query Interface Query Results Query the API
Treatments By Volume Volume (see allowed values) [[Volume::Volume 17]] Try it! Treatments published in volume 17, R script

Python script

Contributors

Properties Used Query Syntax Query Interface Query Results Query the API
Treatments by Author Author [[Author::Bruce A. Ford]] Try it! Treatments authored by Bruce A. Ford, R script

Python script

Morphology

A property browser is in development to facilitate the exploration of the morphological properties. Here are a few sample queries to illustrate the power of parsed morphological data derived from FNA treatments.

Properties Used Query Syntax Query Interface Query Results Query the API
Taxa by corolla coloration Corolla coloration (explore available values) [[Corolla coloration::yellow]] Try it! Taxa with yellow corolla coloration, R script

Python script

Taxa by leaf arrangement Leaf arrangement (explore available values) [[Leaf arrangement::alternate]] Try it! Taxa with alternate leaf arrangement, R script

Python script

Taxa by blade shape Blade shape (explore available values) [[Blade shape::elliptic]] Try it! Taxa with elliptic blade shape, R script

Python script

Advanced Queries

Composite Queries

You can combine any query elements from the above subjects to create a custom search.

For example,

Taxa with authority Linnaeus that occur in Nunavut [[Authority::Linnaeus]][[Distribution::Nunavut]]
Introduced species published in volume 3 [[Special status::Introduced]][[Volume::Volume 3]]
Taxa published before 1754 in the family Cyperaceae [[Publication year::<<1754]][[Taxon family::Cyperaceae]]

Comparators

You can use comparators with the Publication year property. (e.g., >, <, ).

Return More Information

You can return as many additional properties as you wish:

Query interface Query the API
Add property names to the Additional data to display box Add properties using the |? syntax:

[[Authority::Linnaeus]][[Distribution::Nunavut]]|?Taxon family|?Taxon rank|?Author

Write Your Own Queries

Click here to access the Semantic search query interface directly.

Note that:

  • The limit on the number of results returned can be changed
  • You can only export what is displayed on the page (JSON, CSV, RSS, RDF)
    • Page through the results to download each batch

Why use the API convenience scripts?

  1. For big queries, it may be cumbersome to download each batch of 500 results separately and then merge the results.
  2. If you are performing your analyses in R or Python, you may wish to embed the data extraction here, so that it can be easily re-run.

Access the convenience scripts here: https://github.com/jocelynpender/fna-query

Query Resources

Semantic MediaWiki Query Syntax

https://www.semantic-mediawiki.org/wiki/Help:Semantic_search

https://www.semantic-mediawiki.org/wiki/Help:Search_operators

Merging Multiple CSV Files

R script for merging multiple CSV files.

Working with APIs

Convenience scripts

https://github.com/jocelynpender/fna-query

Python

https://mwclient.readthedocs.io/en/latest/index.html

R

https://cran.r-project.org/web/packages/WikipediR/WikipediR.pdf