1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

v2.11.2.1

This commit is contained in:
gnosygnu
2015-11-08 23:48:07 -05:00
parent b990ec409f
commit d9f45cec19
298 changed files with 3908 additions and 2141 deletions

View File

@@ -304,12 +304,12 @@ public class Scrib_lib_mw implements Scrib_lib {
byte[] ttl_bry = Bry_.new_u8(ttl_str);
Xoa_ttl ttl = Xoa_ttl.parse(cur_wiki, ttl_bry); // parse directly; handles titles where template is already part of title; EX: "Template:A"
if (ttl == null) return rslt.Init_ary_empty(); // invalid ttl;
if (!ttl.ForceLiteralLink() && ttl.Ns().Id_main()) // title is not literal and is not prefixed with Template; parse again as template; EX: ":A" and "Template:A" are fine; "A" is parsed again as "Template:A"
if (!ttl.ForceLiteralLink() && ttl.Ns().Id_is_main()) // title is not literal and is not prefixed with Template; parse again as template; EX: ":A" and "Template:A" are fine; "A" is parsed again as "Template:A"
ttl = Xoa_ttl.parse(cur_wiki, Bry_.Add(cur_wiki.Ns_mgr().Ns_template().Name_db_w_colon(), ttl_bry)); // parse again, but add "Template:"
KeyVal[] args_ary = args.Pull_kv_ary(2);
// BLOCK.bgn:Xot_invk_tkn.Transclude; cannot reuse b/c Transclude needs invk_tkn, and invk_tkn is manufactured late; DATE:2014-01-02
byte[] sub_src = null;
if (ttl.Ns().Id_tmpl()) { // ttl is template; check tmpl_regy first before going to data_mgr
if (ttl.Ns().Id_is_tmpl()) { // ttl is template; check tmpl_regy first before going to data_mgr
Xot_defn_tmpl tmpl = (Xot_defn_tmpl)core.Wiki().Cache_mgr().Defn_cache().Get_by_key(ttl.Page_db());
if (tmpl != null) sub_src = tmpl.Data_raw();
}

View File

@@ -30,7 +30,7 @@ public class Scrib_lib_mw__invoke_tst {
@Test public void GetAllExpandedArguments_ws_prm_key_missing() { // PURPOSE: do not trim val if key missing; parameterized value ("{{{1}}}")
fxt.Init_tmpl("{{#invoke:Mod_0|Prc_0|{{{1}}}}}");
fxt.Init_page("{{test| a }}");
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getAllExpandedArguments, Object_.Ary("current"), "\n a "); // " a " -> " a "
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getAllExpandedArguments, Object_.Ary("current"), "\n a"); // " a " -> " a" // tmpl.trim_end: always trim end; DATE:2015-11-07
}
@Test public void GetAllExpandedArguments__ignore_empty_key() {// PURPOSE: ignore arguents that have an empty key (|=8|); EX:w:Fool's_mate; DATE:2014-03-05
fxt.Init_tmpl("{{#invoke:Mod_0|Prc_0}}");
@@ -45,7 +45,7 @@ public class Scrib_lib_mw__invoke_tst {
}
@Test public void GetExpandedArgument_ws_key_missing() { // PURPOSE: do not trim val if key missing; literal value
fxt.Init_page("{{#invoke:Mod_0|Prc_0| a }}");
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getExpandedArgument, Object_.Ary("current", "1") , " a "); // " a " -> " a "
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getExpandedArgument, Object_.Ary("current", "1") , " a"); // " a " -> " a" // tmpl.trim_end: always trim end; DATE:2015-11-07
}
@Test public void GetExpandedArgument_ws_key_prm_key_exists() { // PURPOSE: trim val if key exists; parameterized value ("key={{{1}}}")
fxt.Init_tmpl("{{#invoke:Mod_0|Prc_0|key1={{{1}}}}}");
@@ -55,7 +55,7 @@ public class Scrib_lib_mw__invoke_tst {
@Test public void GetExpandedArgument_ws_key_prm_key_missing() { // PURPOSE: do not trim val if key missing; parameterized value ("{{{1}}}")
fxt.Init_tmpl("{{#invoke:Mod_0|Prc_0|{{{1}}}}}");
fxt.Init_page("{{test| a }}");
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getExpandedArgument, Object_.Ary("current", "1") , " a "); // " a " -> " a "
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getExpandedArgument, Object_.Ary("current", "1") , " a"); // " a " -> " a" // tmpl.trim_end: always trim end; DATE:2015-11-07
}
@Test public void Preprocess() {
this.Init_preprocess();

View File

@@ -140,20 +140,20 @@ public class Scrib_lib_site implements Scrib_lib {
}
private KeyVal[] Bld_ns(Xowe_wiki wiki, Xow_ns ns, int ns_id) {
int len = 16;
if (ns_id < Xow_ns_.Id_main) len = 14;
else if (ns_id == Xow_ns_.Id_main) len = 17;
if (ns_id < Xow_ns_.Tid__main) len = 14;
else if (ns_id == Xow_ns_.Tid__main) len = 17;
KeyVal[] rv = new KeyVal[len];
rv[ 0] = KeyVal_.new_("id" , ns_id);
rv[ 1] = KeyVal_.new_("name" , ns.Name_txt());
rv[ 2] = KeyVal_.new_("canonicalName" , ns.Name_str()); // strtr( $canonical, "_", " " ),
rv[ 1] = KeyVal_.new_("name" , ns.Name_ui());
rv[ 2] = KeyVal_.new_("canonicalName" , ns.Name_db_str()); // strtr( $canonical, "_", " " ),
rv[ 3] = KeyVal_.new_("hasSubpages" , ns.Subpages_enabled()); // MWNs::hasSubpages( $ns ),
rv[ 4] = KeyVal_.new_("hasGenderDistinction" , ns.Is_gender_aware()); // MWNs::hasGenderDistinction( $ns ),
rv[ 5] = KeyVal_.new_("isCapitalized" , ns.Is_capitalized()); // MWNs::isCapitalized( $ns ),
rv[ 6] = KeyVal_.new_("isContent" , ns.Is_content()); // MWNs::isContent( $ns ),
rv[ 7] = KeyVal_.new_("isIncludable" , ns.Is_includable()); // !MWNs::isNonincludable( $ns ),
rv[ 8] = KeyVal_.new_("isMovable" , ns.Is_movable()); // MWNs::isMovable( $ns ),
rv[ 9] = KeyVal_.new_("isSubject" , ns.Id_subj());
rv[10] = KeyVal_.new_("isTalk" , ns.Id_talk());
rv[ 9] = KeyVal_.new_("isSubject" , ns.Id_is_subj());
rv[10] = KeyVal_.new_("isTalk" , ns.Id_is_talk());
rv[11] = KeyVal_.new_("defaultContentModel" , null); // MWNs::getNsContentModel( $ns ), ASSUME: always null?
rv[12] = KeyVal_.new_("aliases" , ns.Aliases_as_scrib_ary()); // DATE:2014-02-15
if (ns_id < 0)
@@ -162,7 +162,7 @@ public class Scrib_lib_site implements Scrib_lib {
rv[13] = KeyVal_.new_("subject" , ns_id); // MWNs::getSubject( $ns );
rv[14] = KeyVal_.new_("talk" , ns.Id_talk_id()); // MWNs::getTalk( $ns );
rv[15] = KeyVal_.new_("associated" , ns.Id_alt_id()); // MWNs::getAssociated( $ns );
if (ns_id == Xow_ns_.Id_main)
if (ns_id == Xow_ns_.Tid__main)
rv[16] = KeyVal_.new_("displayName" , wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_ns_blankns)); // MWNs::getAssociated( $ns );
}
return rv;

View File

@@ -42,11 +42,11 @@ public class Scrib_lib_site_tst {
fxt.Parser_fxt().Wiki().Stats().NumPages_(1).NumArticles_(2).NumFiles_(3).NumEdits_(4).NumViews_(5).NumUsers_(6).NumUsersActive_(7).NumAdmins_(8);
wiki.Ns_mgr()
.Clear()
.Add_new(Scrib_xtn_mgr.Ns_id_module, "Module")
.Add_new(Scrib_xtn_mgr.Ns_id_module_talk, "Module talk")
.Add_new(Xow_ns_.Id_special, "Special")
.Add_new(Xow_ns_.Id_main, "")
.Add_new(Xow_ns_.Id_talk, "Talk")
.Add_new(Xow_ns_.Tid__module , Xow_ns_.Key__module)
.Add_new(Xow_ns_.Tid__module_talk , Xow_ns_.Key__module_talk)
.Add_new(Xow_ns_.Tid__special , Xow_ns_.Key__special)
.Add_new(Xow_ns_.Tid__main , "")
.Add_new(Xow_ns_.Tid__talk , Xow_ns_.Key__talk)
.Init_w_defaults()
;
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_site.Invk_init_site_for_wiki, Object_.Ary_empty, String_.Concat_lines_nl_skip_last

View File

@@ -29,7 +29,7 @@ public class Scrib_lib_title implements Scrib_lib {
Init();
mod = core.RegisterInterface(this, script_dir.GenSubFil("mw.title.lua")
, KeyVal_.new_("thisTitle", "") // NOTE: pass blank; will be updated by GetCurrentTitle
, KeyVal_.new_("NS_MEDIA", Xow_ns_.Id_media) // NOTE: MW passes down NS_MEDIA; this should be -2 on all wikis...
, KeyVal_.new_("NS_MEDIA", Xow_ns_.Tid__media) // NOTE: MW passes down NS_MEDIA; this should be -2 on all wikis...
);
notify_page_changed_fnc = mod.Fncs_get_by_key("notify_page_changed");
return mod;
@@ -108,7 +108,7 @@ public class Scrib_lib_title implements Scrib_lib {
int ns_id = Int_.cast(ns_obj);
Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
if (ns != null)
return ns.Name_bry();
return ns.Name_db();
}
return null;
}
@@ -153,9 +153,9 @@ public class Scrib_lib_title implements Scrib_lib {
Xowe_wiki wiki = core.Wiki();
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
if ( ttl == null
|| !ttl.Ns().Id_file_or_media()
|| !ttl.Ns().Id_is_file_or_media()
) return rslt.Init_obj(GetFileInfo_absent);
if (ttl.Ns().Id_media()) ttl = Xoa_ttl.parse(wiki, Xow_ns_.Id_file, ttl.Page_db()); // if [[Media:]] change to [[File:]]; theoretically, this should be changed in Get_page, but not sure if I want to put this logic that low; DATE:2014-01-07
if (ttl.Ns().Id_is_media()) ttl = Xoa_ttl.parse(wiki, Xow_ns_.Tid__file, ttl.Page_db()); // if [[Media:]] change to [[File:]]; theoretically, this should be changed in Get_page, but not sure if I want to put this logic that low; DATE:2014-01-07
// Xoae_page file_page = Pfunc_filepath.Load_page(wiki, ttl); // EXPENSIVE
// boolean exists = !file_page.Missing();
// if (!exists) return rslt.Init_obj(KeyVal_.Ary(KeyVal_.new_("exists", false))); // NOTE: do not reinstate; will exit early if commons is not installed; DATE:2015-01-25; NOTE: Media objects are often flagged as absent in offline mode
@@ -207,24 +207,24 @@ public class Scrib_lib_title implements Scrib_lib {
public static final KeyVal[] CascadingProtection_rv = KeyVal_.Ary(KeyVal_.new_("sources", Bool_.N), KeyVal_.new_("restrictions", KeyVal_.Ary_empty));
private KeyVal[] GetInexpensiveTitleData(Xoa_ttl ttl) {
Xow_ns ns = ttl.Ns();
boolean ns_file_or_media = ns.Id_file_or_media(), ns_special = ns.Id_special();
boolean ns_file_or_media = ns.Id_is_file_or_media(), ns_special = ns.Id_is_special();
int rv_len = 7, rv_idx = 7;
if (ns_special) ++rv_len;
if (!ns_file_or_media) ++rv_len;
Xow_xwiki_itm xwiki_itm = ttl.Wik_itm();
String xwiki_str = xwiki_itm == null ? "" : xwiki_itm.Key_str();
KeyVal[] rv = new KeyVal[rv_len];
rv[ 0] = KeyVal_.new_("isLocal" , true); // title.isLocal; NOTE: always true; passing "http:" also returns true; not sure how to handle "Interwiki::fetch( $this->mInterwiki )->isLocal()"
rv[ 1] = KeyVal_.new_("interwiki" , xwiki_str); // $title->getInterwiki(),
rv[ 2] = KeyVal_.new_("namespace" , ns.Id()); // $ns,
rv[ 3] = KeyVal_.new_("nsText" , ns.Name_str()); // $title->getNsText(),
rv[ 4] = KeyVal_.new_("text" , ttl.Page_txt()); // $title->getText(),
rv[ 5] = KeyVal_.new_("fragment" , ttl.Anch_txt()); // $title->getFragment(),
rv[ 6] = KeyVal_.new_("thePartialUrl" , ttl.Page_db()); // $title->getPartialUrl(),
rv[ 0] = KeyVal_.new_("isLocal" , true); // title.isLocal; NOTE: always true; passing "http:" also returns true; not sure how to handle "Interwiki::fetch( $this->mInterwiki )->isLocal()"
rv[ 1] = KeyVal_.new_("interwiki" , xwiki_str); // $title->getInterwiki(),
rv[ 2] = KeyVal_.new_("namespace" , ns.Id()); // $ns,
rv[ 3] = KeyVal_.new_("nsText" , Xow_ns_canonical_.To_canonical_or_local(ns)); // $title->getNsText(), NOTE: needed b/c some modules expect English "Template"; PAGE:sh.w:Koprno DATE:2015-11-08
rv[ 4] = KeyVal_.new_("text" , ttl.Page_txt()); // $title->getText(),
rv[ 5] = KeyVal_.new_("fragment" , ttl.Anch_txt()); // $title->getFragment(),
rv[ 6] = KeyVal_.new_("thePartialUrl" , ttl.Page_db()); // $title->getPartialUrl(),
if (ns_special)
rv[rv_idx++] = KeyVal_.new_("exists" , false); // TODO: lookup specials
rv[rv_idx++] = KeyVal_.new_("exists" , false); // TODO: lookup specials
if (!ns_file_or_media)
rv[rv_idx++] = KeyVal_.new_("file" , false); // REF.MW: if ( $ns !== NS_FILE && $ns !== NS_MEDIA ) $ret['file'] = false;
rv[rv_idx++] = KeyVal_.new_("file" , false); // REF.MW: if ( $ns !== NS_FILE && $ns !== NS_MEDIA ) $ret['file'] = false;
return rv;
} private static final Xowd_page_itm tmp_db_page = Xowd_page_itm.new_tmp();
public static final String Key_wikitexet = "wikitext";

View File

@@ -32,6 +32,10 @@ public class Scrib_lib_title_tst {
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("A", "Template") , ttl_fast(10 , "Template", "A"));
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("a[b") , Scrib_invoke_func_fxt.Null_rslt_ary); // invalid
}
@Test public void NewTitle__foreign() {// PURPOSE: always return English name b/c some modules expect English "Template"; PAGE:sh.w:Koprno DATE:2015-11-08
fxt.Core().Wiki().Ns_mgr().Ns_template().Name_bry_(Bry_.new_a7("Template_in_nonenglish_name"));
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("A", "Template") , ttl_fast(10 , "Template", "A")); // "Template" not "Template_in_nonenglish_name"
}
@Test public void GetUrl() {
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl") , "//en.wikipedia.org/wiki/Main_Page");
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl", "action=edit") , "//en.wikipedia.org/wiki/Main_Page?action=edit");
@@ -155,15 +159,3 @@ public class Scrib_lib_title_tst {
);
}
}
//0000: '' != '1=isLocal=True'
//0001: ' true;false;;828;Module;A;0;;wikitext;A;false;false' != 'isRedirect=False'
//0002: <<N/A>> != 'interwiki='
//0003: <<N/A>> != 'namespace=828'
//0004: <<N/A>> != 'nsText=Module'
//0005: <<N/A>> != 'text=A'
//0006: <<N/A>> != 'id=0'
//0007: <<N/A>> != 'fragment='
//0008: <<N/A>> != 'contentModel=wikitext'
//0009: <<N/A>> != 'thePartialUrl=A'
//0010: <<N/A>> != 'exists=False'
//0011: <<N/A>> != 'fileExists=False'

View File

@@ -60,7 +60,7 @@ public class Scrib_lib_uri implements Scrib_lib {
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
if (ttl == null) return rslt.Init_null();
Bry_bfr bfr = core.App().Utl__bfr_mkr().Get_b512();
if (ttl.Ns().Id() == Xow_ns_.Id_media) { // change "Media:" -> "File:"
if (ttl.Ns().Id() == Xow_ns_.Tid__media) { // change "Media:" -> "File:"
bfr.Add(wiki.Ns_mgr().Ns_file().Name_db_w_colon());
bfr.Add(ttl.Page_db());
ttl_bry = bfr.To_bry_and_clear();

View File

@@ -48,7 +48,9 @@ public class Scrib_lib_wikibase_entity implements Scrib_lib {
Wdata_wiki_mgr wdata_mgr = app.Wiki_mgr().Wdata_mgr();
byte[] lang = wiki.Wdata_wiki_lang();
Wdata_doc wdoc = wdata_mgr.Pages_get(qid); if (wdoc == null) {Wdata_wiki_mgr.Log_missing_qid(core.Ctx(), qid); return rslt.Init_str_empty();} // NOTE: return empty String, not nil; PAGE:fr.s:Henri_Bergson; DATE:2014-08-13
int pid_int = wdata_mgr.Pids_get(lang, pid); if (pid_int == Wdata_wiki_mgr.Pid_null) return rslt.Init_str_empty();
int pid_int = wdata_mgr.Pids__parse_as_int_or_null(pid); // parse as num; EX: p123 -> 123; PAGE:hr.w:Hepatitis DATE:2015-11-08
if (pid_int == Wdata_wiki_mgr.Pid_null) pid_int = wdata_mgr.Pids__get_by_name(lang, pid); // parse as name; EX: name > 123
if (pid_int == Wdata_wiki_mgr.Pid_null) return rslt.Init_str_empty();
Wdata_claim_grp prop_grp = wdoc.Claim_list_get(pid_int); if (prop_grp == null) return rslt.Init_str_empty();
Bry_bfr bfr = app.Utl__bfr_mkr().Get_b512();
wdata_mgr.Resolve_to_bfr(bfr, prop_grp, lang);

View File

@@ -29,8 +29,9 @@ public class Scrib_lib_wikibase_entity_tst {
@Test public void FormatPropertyValues() {
Wdata_wiki_mgr_fxt wdata_fxt = new Wdata_wiki_mgr_fxt().Init(fxt.Parser_fxt(), false);
wdata_fxt.Init_pages_add(wdata_fxt.Wdoc_bldr("Q2").Add_claims(wdata_fxt.Make_claim_str(3, "P3_val")).Xto_wdoc());
wdata_fxt.Init_pids_add("en", "P3", 3);
fxt.Test_scrib_proc_str(lib, Scrib_lib_wikibase_entity.Invk_formatPropertyValues, Object_.Ary("Q2", "P3"), "P3_val");
fxt.Test_scrib_proc_str(lib, Scrib_lib_wikibase_entity.Invk_formatPropertyValues, Object_.Ary("Q2", "P3") , "P3_val"); // lookup by id
wdata_fxt.Init_pids_add("en", "P3_val", 3);
fxt.Test_scrib_proc_str(lib, Scrib_lib_wikibase_entity.Invk_formatPropertyValues, Object_.Ary("Q2", "P3_val") , "P3_val"); // lookup by name
}
@Test public void FormatPropertyValues__not_found() { // PURPOSE: should return "" not null; PAGE:fr.s:Auteur:Henri_Bergson; DATE:2014-08-13
fxt.Test_scrib_proc_str(lib, Scrib_lib_wikibase_entity.Invk_formatPropertyValues, Object_.Ary("Q2", "P3"), "");

View File

@@ -141,11 +141,12 @@ class Scrib_lib_wikibase_srl {
private static KeyVal[] Srl_claims_prop_itm_core(String pid, Wdata_claim_itm_core itm) {
boolean snak_is_valued = itm.Snak_tid() != Wdata_dict_snak_tid.Tid_novalue;
int snak_is_valued_adj = snak_is_valued ? 1 : 0;
KeyVal[] rv = new KeyVal[2 + snak_is_valued_adj];
KeyVal[] rv = new KeyVal[3 + snak_is_valued_adj];
if (snak_is_valued) // NOTE: novalue must not return slot (no datavalue node in json); PAGE:ru.w:Лимонов,_Эдуард_Вениаминович; DATE:2015-02-16; ALSO: sv.w:Joseph_Jaquet; DATE:2015-07-31
rv[0] = KeyVal_.new_("datavalue", Srl_claims_prop_itm_core_val(itm));
rv[0 + snak_is_valued_adj] = KeyVal_.new_("property", pid);
rv[1 + snak_is_valued_adj] = KeyVal_.new_("snaktype", Wdata_dict_snak_tid.Xto_str(itm.Snak_tid()));
rv[2 + snak_is_valued_adj] = KeyVal_.new_("datatype", Wdata_dict_val_tid.To_str__srl(itm.Val_tid())); // NOTE: datatype needed for Modules; PAGE:eo.w:WikidataKoord; DATE:2015-11-08
return rv;
}
private static final Scrib_lib_wikibase_srl_visitor visitor = new Scrib_lib_wikibase_srl_visitor();

View File

@@ -138,6 +138,7 @@ public class Scrib_lib_wikibase_srl_tst {
, " value:'Moon'"
, " property:'P2'"
, " snaktype:'value'"
, " datatype:'string'"
, " rank:'normal'"
, " type:'statement'"
, ""
@@ -156,6 +157,7 @@ public class Scrib_lib_wikibase_srl_tst {
, " value:''"
, " property:'P2'"
, " snaktype:'somevalue'"
, " datatype:'unknown'"
, " rank:'normal'"
, " type:'statement'"
, ""
@@ -171,6 +173,7 @@ public class Scrib_lib_wikibase_srl_tst {
, " mainsnak:"
, " property:'P2'"
, " snaktype:'novalue'"
, " datatype:'unknown'"
, " rank:'normal'"
, " type:'statement'"
, ""
@@ -191,6 +194,7 @@ public class Scrib_lib_wikibase_srl_tst {
, " numeric-id:'3'"
, " property:'P2'"
, " snaktype:'value'"
, " datatype:'wikibase-entityid'"
, " rank:'normal'"
, " type:'statement'"
, ""
@@ -211,6 +215,7 @@ public class Scrib_lib_wikibase_srl_tst {
, " numeric-id:'3'"
, " property:'P2'"
, " snaktype:'value'"
, " datatype:'wikibase-entityid'"
, " rank:'normal'"
, " type:'statement'"
, " p2:"
@@ -224,6 +229,7 @@ public class Scrib_lib_wikibase_srl_tst {
, " numeric-id:'3'"
, " property:'P2'"
, " snaktype:'value'"
, " datatype:'wikibase-entityid'"
, " rank:'normal'"
, " type:'statement'"
, ""
@@ -248,6 +254,7 @@ public class Scrib_lib_wikibase_srl_tst {
, " calendarmodel:'http://www.wikidata.org/entity/Q1985727'"
, " property:'P2'"
, " snaktype:'value'"
, " datatype:'time'"
, " rank:'normal'"
, " type:'statement'"
, ""
@@ -271,6 +278,7 @@ public class Scrib_lib_wikibase_srl_tst {
, " precision:'1.0E-5'"
, " property:'P2'"
, " snaktype:'value'"
, " datatype:'globe-coordinate'"
, " rank:'normal'"
, " type:'statement'"
, ""
@@ -287,12 +295,13 @@ public class Scrib_lib_wikibase_srl_tst {
, " datavalue:"
, " type:'quantity'"
, " value:"
, " amount:'+1,234'"
, " amount:'1234'"
, " unit:'2'"
, " upperBound:'+1,236'"
, " lowerBound:'+1232'"
, " upperBound:'1236'"
, " lowerBound:'1232'"
, " property:'P2'"
, " snaktype:'value'"
, " datatype:'quantity'"
, " rank:'normal'"
, " type:'statement'"
, ""
@@ -313,6 +322,7 @@ public class Scrib_lib_wikibase_srl_tst {
, " language:'en'"
, " property:'P2'"
, " snaktype:'value'"
, " datatype:'monolingualtext'"
, " rank:'normal'"
, " type:'statement'"
, ""
@@ -332,6 +342,7 @@ public class Scrib_lib_wikibase_srl_tst {
, " value:'Earth'"
, " property:'P2'"
, " snaktype:'value'"
, " datatype:'string'"
, " rank:'normal'"
, " type:'statement'"
, " qualifiers:"
@@ -348,6 +359,7 @@ public class Scrib_lib_wikibase_srl_tst {
, " calendarmodel:'http://www.wikidata.org/entity/Q1985727'"
, " property:'P3'"
, " snaktype:'value'"
, " datatype:'time'"
, ""
);
}

View File

@@ -54,10 +54,10 @@ class Scrib_lib_wikibase_srl_visitor implements Wdata_claim_visitor {
}
private static KeyVal[] Quantity_value(Wdata_claim_itm_quantity itm) {
KeyVal[] rv = new KeyVal[4];
rv[0] = KeyVal_.new_(Wdata_dict_value_quantity.Str_amount , String_.new_u8(itm.Amount()));
rv[0] = KeyVal_.new_(Wdata_dict_value_quantity.Str_amount , itm.Amount_as_num().To_str()); // NOTE: must be num b/c Module code will directly do math calc on it; EX: "99" not "+99"; PAGE:eo.w:Mud<75>; DATE:2015-11-08
rv[1] = KeyVal_.new_(Wdata_dict_value_quantity.Str_unit , String_.new_u8(itm.Unit()));
rv[2] = KeyVal_.new_(Wdata_dict_value_quantity.Str_upperbound , String_.new_u8(itm.Ubound()));
rv[3] = KeyVal_.new_(Wdata_dict_value_quantity.Str_lowerbound , String_.new_u8(itm.Lbound()));
rv[2] = KeyVal_.new_(Wdata_dict_value_quantity.Str_upperbound , itm.Ubound_as_num().To_str());
rv[3] = KeyVal_.new_(Wdata_dict_value_quantity.Str_lowerbound , itm.Lbound_as_num().To_str());
return rv;
}
public void Visit_time(Wdata_claim_itm_time itm) {