As an anonymous user, you can only add new data. If you would like to also modify existing data, please create an account and indicate your languages on your user page.

Help:OmegaWiki API

From OmegaWiki
(Redirected from Help:API)
Jump to: navigation, search

This page describes the elements of the API specific to OmegaWiki. All the functionalities of the standard MediaWiki API are also available.

Obtaining data[edit]

ow_express[edit]

Returns information about the concepts ( DefinedMeaning ) and definitions of a given expression.

Parameters:

  • search, The expression being searched
  • ver, module version

Examples[edit]

The following example returns information about the concept and definition of the given expression.

http://www.omegawiki.org/api.php?action=ow_express&search=acusar&format=json

Version 1.1 returns information that is better for a javascript client. To use this, just add ver=1.1

http://www.omegawiki.org/api.php?action=ow_express&ver=1.1&search=acusar&format=json (NOTE: not yet implemented.)

ow_define[edit]

Returns the definition of a DefinedMeaning in a specified language. Also returns the translation in that language.

Parameters:

  • dm, defined_meaning_id corresponding to the concept to define
  • lang, language_id of the definition to display

Examples[edit]

The following example defines DM DefinedMeaning:word_(6551) (word) in English (lang=85):

http://www.omegawiki.org/api.php?action=ow_define&lang=85&dm=6551&format=jsonfm

ow_syntrans[edit]

Returns information about the synonyms and translations of a given concept (DefinedMeaningId)

Necessary parameter:

  • dm, defined_meaning_id corresponding to the concept to define

Optional parameters

  • part: syn for synonyms and trans for translations. Requires lang.
  • lang: the language of the synonyms, or the language to translate in translations.
  • e: an expression of which one want the synonyms of.

Examples[edit]

1. Returns all syntrans of the concept 8218 (alphabet)

http://www.omegawiki.org/api.php?action=ow_syntrans&dm=8218&format=jsonfm


2. Returns the words (synonyms) that express the concept 8218 (alphabet) in Spanish (lang=87):

http://www.omegawiki.org/api.php?action=ow_syntrans&dm=8218&part=syn&lang=87&format=jsonfm


3. Returns the translations of that Spanish concept

http://www.omegawiki.org/api.php?action=ow_syntrans&dm=8218&part=trans&lang=87&format=jsonfm

Modifying data[edit]

Modifying data requires that the user has a bot flag. Either login manually with your bot account, or use the API login function.

ow_add_definition[edit]

NOTE
This function is not yet available!

Adds a definition in a new language to a given Defined Meaning.

Parameters:

  • d, the definition to be added
  • lang, language_id of the definition to be added
  • dm, defined_meaning_id to which the definition should be added
  • wikipage, for batch processing
  • test, test mode (no changes made to the database)

If a definition already exists for the language lang' and the defined meaning dm, the existing definition is kept.

Adding multiple definitions to their respective Defined Meanings is possible.

Create a wiki page in CSV format. The wiki page must contain three columns:

  • definition (string) - Note: May be enclosed in double quotes. Must be enclosed in double quotes, if the field contains commas.
  • language_id (int)
  • defined_meaning_id (int)

each line of three fields will be treated in turn like above.

ow_add_syntrans[edit]

Adds a translation to a given Defined Meaning.

Parameters:

  • e, spelling of the word to add
  • lang, language_id of the word to add
  • dm, defined_meaning_id to which the word should be added
  • im, identical_meaning (0=not-identical or 1=identical)
  • wikipage, for batch processing
  • test, test mode (no changes made to the database)

The following example adds "word" for English (lang=85) as a translation for DM DefinedMeaning:word_(6551):

To check if what you want to add is correct, use

http://www.omegawiki.org/api.php?action=ow_add_syntrans&e=word&lang=85&dm=6551&im=1&test

To actually add a translation to the DM, use

http://www.omegawiki.org/api.php?action=ow_add_syntrans&e=word&lang=85&dm=6551&im=1

Adding multiple translations to their respective Defined Meanings is possible.

You must create a wiki page (in CSV format).

The wiki page must contain at least 3 columns (and 1 optional column):

  • spelling (string)
  • language_id (int)
  • defined_meaning_id (int)
  • identical meaning (boolean 0=not-identical-meaning, or 1=identical-meaning, optional, default=1=identical-meaning)

Examples:

"先天",107,366495
"先天",135,366495

or with optional column

"先天",107,366495,1
"先天",135,366495,0

see example page:User:Hiong3.eng5/addsyntrans.csv

Once the page is saved, you can use the API to add syntrans using the saved wiki page.

If you want to use the page User:Hiong3.eng5/addsyntrans.csv to add syntrans, all you have to do is use

For checking ...

http://www.omegawiki.org/api.php?action=ow_add_syntrans&wikipage=User:Hiong3.eng5/addsyntrans.csv&format=xml&test

For actual processing of data ...

http://www.omegawiki.org/api.php?action=ow_add_syntrans&wikipage=User:Hiong3.eng5/addsyntrans.csv&format=xml

You could use any formats specified by the API. This would then produce a report of what words were added and which are already present.

ow_add_to_collection[edit]

Adds a DM to a given Collection DM.

Parameters:

  • dm, defined_meaning_id to add
  • coll_id, defined_meaning_id of the collection to which the word should be added
  • int_memb_id, Internal member id, A further string that can be used to identify the member inside the collection
  • wikipage, for batch processing
  • test, test mode (no changes made to the database)

The following example adds DM "DefinedMeaning:animal_(194)" to Collection DM DefinedMeaning:Community_Database_class_(725301):

To check if what you want to add is correct, use

api.php?action=ow_add_to_collection&dm=194&coll_mid=725301&format=xml&test

To actually add the DM to the collection, use

api.php?action=ow_add_to_collection&dm=194&coll_mid=725301&format=xml

Adding multiple DM to a Collection is possible.

You must create a wiki page (in CSV format).

The wiki page must contain at least 3 columns (and 1 optional column):

  • dm (int)
  • coll_id (int)
  • int_memb_id (int) (can be null)

Examples:

194,725301,
194,725301,

see example page:User:Hiong3.eng5/addToCollection.csv

Once the page is saved, you can use the API to add DM to collections using the saved wiki page.

If you want to use the page User:Hiong3.eng5/addToCollection.csv to add DM, all you have to do is use

For checking ...

http://www.omegawiki.org/api.php?action=ow_add_syntrans&wikipage=User:Hiong3.eng5/addToCollection.csv&format=xml&test

For actual processing of data ...

http://www.omegawiki.org/api.php?action=ow_add_syntrans&wikipage=User:Hiong3.eng5/addToCollection.csv&format=xml

You could use any formats specified by the API. This would then produce a report of what words were added and which are already present.

NOTE: It is encouraged to use the test parameter first to avoid errors.

ow_add_annotation[edit]

Adds annotation to a given DM or syntrans.

The API currently supports adding only three types of annotations. Parameter:

type=text[edit]

To add DM annotations.

Parameters:

  • dm, defined_meaning_id to which the text attribute should be added
  • attribute, spelling of the attribute to which the text attribute should be added
  • attrib_lang, language code (iso639_3 of the language table) of the attribute expression to which text attribute should be added
  • text, the text attribute to add
  • wikipage, for batch processing
  • test, test mode (no changes made to the database)

The following example adds text attribute value "Fe" to text attribute chemical symbol for DM DefinedMeaning:iron%20(2024). The attribute expression chemical symbol is in English (attrib_lang=eng).

To check if what you want to add is correct, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=text&dm=2024&attribute=chemical%20symbol&attrib_lang=eng&text=Fe&format=json&test

To actually add an annotation to the DM, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=text&dm=2024&attribute=chemical%20symbol&attrib_lang=eng&text=Fe&format=json

To add syntrans annotations, two additional parameters are required.

Parameters:

  • e, spelling of the text attribute to add
  • lang, language code (iso639_3 of the language table) of the text attribute to add

The following example adds text attribute value "a·cu·sar" to text attribute hyphenation for Spanish (lang=spa) expression Expression:acusar with DM DefinedMeaning:betray%20(837820). The attribute expression hyphenation is in English (attrib_lang=eng).

To check if what you want to add is correct, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=text&e=acusar&lang=spa&dm=837820&attribute=hyphenation&attrib_lang=eng&text=a·cu·sar&format=xml&test

To actually add an annotation to the Synonym/Translation, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=text&e=acusar&lang=spa&dm=837820&attribute=hyphenation&attrib_lang=eng&text=a·cu·sar&format=xml

Adding multiple annotations to their respective Defined Meanings/Syntrans is possible.

You must create a wiki page (in TSV format).

The wiki page must contain at least 4 columns (and 2 optional columns):

  • defined_meaning_id (int)
  • attribute (string)
  • attribute language (string)
  • text (string)
  • expression (string) (optional)
  • language (string) (optional)

Examples:

for dm

2024	"chemical symbol"	"eng"	"Fe"		
2024	"atomic number"	eng	26

or for syntrans

837820	"hyphenation"	"eng"	"a·cu·sar"	"acusar"	"spa"

see example page:User:Minnan.import.bot/addTextAnnotation

Once the page is saved, you can use the API to add syntrans using the saved wiki page.

If you want to use the page User:Minnan.import.bot/addTextAnnotation to add annotations, all you have to do is use

For checking ...

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=text&wikipage=User:Minnan.import.bot/addTextAnnotation&dm=0&format=xml&test

For actual processing of data ...

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=text&wikipage=User:Minnan.import.bot/addTextAnnotation&dm=0&format=xml

You could use any formats specified by the API. This would then produce a report of what words were added and which are already present.

type=option[edit]

To add DM annotations.

Parameters:

  • dm, defined_meaning_id to which the option attribute should be added
  • attribute, spelling of the attribute to which the option attribute should be added
  • attrib_lang, language code (iso639_3 of the language table) of the attribute expression to which the option attribute should be added
  • option, the option attribute to add
  • option_lang, language code (iso639_3 of the language table) of the option expression to which option attribute should be added
  • wikipage, for batch processing
  • test, test mode (no changes made to the database)

The following example adds the English (option_lang=eng) option attribute value "biology" for option attribute topic for DM DefinedMeaning:reproduction%20(biological)%20(3188). The attribute expression topic is in English (attrib_lang=eng).

To check if what you want to add is correct, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=option&dm=3188&attribute=topic&attrib_lang=eng&option=biology&option_lang=eng&format=xml&test

To actually add an annotation to the DM, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=option&dm=3188&attribute=topic&attrib_lang=eng&option=biology&option_lang=eng&format=xml

To add syntrans annotations, two additional parameters are required.

Parameters:

  • e, spelling of the option attribute to add
  • lang, language code (iso639_3 of the language table) of the option attribute to add

The following example adds the English (option_lang=eng) option attribute value "verb" to option attribute part of speech for Spanish (lang=spa) expression Expression:acusar with DM DefinedMeaning:betray%20(837820). The attribute expression part of speech is in English (option_lang=eng).

To check if what you want to add is correct, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=option&e=acusar&lang=spa&dm=837820&attribute=part%20of%20speech&attrib_lang=eng&option=verb&option_lang=eng&format=xml&test

To actually add an annotation to the Synonym/Translation, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=option&e=acusar&lang=spa&dm=837820&attribute=part%20of%20speech&attrib_lang=eng&option=verb&option_lang=eng&format=xml

Adding multiple annotations to their respective Defined Meanings/Syntrans is possible.

You must create a wiki page (in TSV format).

The wiki page must contain at least 5 columns (and 2 optional columns):

  • defined_meaning_id (int)
  • attribute (string)
  • attribute language (string)
  • option (string)
  • option language (string)
  • expression (string) (optional)
  • language (string) (optional)

Examples:

for dm

3188	"topic"	"eng"	"biology"	"eng"

or for syntrans

837820	part of speech	eng	verb	eng	acusar	spa
7367	usage	eng	colloquial	eng	case	eng

see example page:User:Minnan.import.bot/addOptionAnnotation

Once the page is saved, you can use the API to add syntrans using the saved wiki page.

If you want to use the page User:Minnan.import.bot/addOptionAnnotation to add annotations, all you have to do is use

For checking ...

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=option&wikipage=User:Minnan.import.bot/addOptionAnnotation&dm=0&format=xml&test

For actual processing of data ...

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=option&wikipage=User:Minnan.import.bot/addOptionAnnotation&dm=0&format=xml

You could use any formats specified by the API. This would then produce a report of what words were added and which are already present.

type=relation[edit]

To add DM annotations.

Parameters:

  • dm, defined_meaning_id to which the relation attribute should be added
  • attribute, spelling of the attribute to which the relation attribute should be added
  • attrib_lang, language code (iso639_3 of the language table) of the attribute expression to which the relation attribute should be added
  • dm_relation, Defined meaning id of the relation attribute to add

The following example adds relation attribute value "DefinedMeaning:metal%20(2324)" to attribute hypernym for DM DefinedMeaning:iron%20(2024). The attribute expression hypernym is in English (attrib_lang=eng).

To check if what you want to add is correct, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=relation&dm=2024&attribute=hypernym&attrib_lang=eng&dm_relation=2324&test

To actually add an annotation to the DM, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=relation&dm=2024&attribute=hypernym&attrib_lang=eng&dm_relation=2324

To add syntrans annotations.

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=relation&dm=2024&attribute=hypernym&attrib_lang=eng&dm_relation=2324

Parameters:

  • dm, defined_meaning_id to which the relation attribute should be added
  • attribute, spelling of the attribute to which the relation attribute should be added
  • attrib_lang, language code (iso639_3 of the language table) of the attribute expression to which the relation attribute should be added
  • relation, the relation attribute to add
  • relation_lang, language code (iso639_3 of the language table) of the relation expression to which relation attribute should be added
  • e, spelling of the relation attribute to add
  • lang, language code (iso639_3 of the language table) of the relation attribute to add

The following example adds Min Nan (POJ) (relation_lang=nan-POJ) relation attribute value "" to attribute dialectal variant for Min Nan (POJ) (lang=nan-POJ) expression with DM DefinedMeaning:betray%20(837820). The attribute expression dialectal variant is in English (attrib_lang=eng).

To check if what you want to add is correct, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=relation&e=jí&lang=nan-poj&dm=5453&attribute=dialectal%20variant&attrib_lang=eng&relation=lí&relation_lang=nan-poj&test

To actually add an annotation to the Synonym/Translation, use

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=relation&e=jí&lang=nan-poj&dm=5453&attribute=dialectal%20variant&attrib_lang=eng&relation=lí&relation_lang=nan-poj

Adding multiple annotations to their respective Defined Meanings/Syntrans is possible.

You must create a wiki page (in TSV format).

The wiki page must contain 8 columns:

  • defined_meaning_id (int)
  • attribute (string)
  • attribute language (string)
  • relation (string)
  • relation language (string)
  • expression (string)
  • language (string)
  • dm relation (int)

Examples:

for dm

2024	hypernym	eng					2324

or for syntrans

5453	dialectal variant	eng	lí	nan-POJ	jí	nan-POJ	

see example page:User:Minnan.import.bot/addRelationAnnotation

Once the page is saved, you can use the API to add syntrans using the saved wiki page.

If you want to use the page User:Minnan.import.bot/addRelationAnnotation to add annotations, all you have to do is use

For checking ...

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=relation&wikipage=User:Minnan.import.bot/addRelationAnnotation&dm=0&format=xml&test

For actual processing of data ...

http://www.omegawiki.org/api.php?action=ow_add_annotation&type=relation&wikipage=User:Minnan.import.bot/addRelationAnnotation&dm=0&format=xml

You could use any formats specified by the API. This would then produce a report of what words were added and which are already present.

see also[edit]