Is there any Freebase dump that includes all the data along with the schema as well? It should have the complete Freebase data as if it was deployed inside Metaweb. Is there any dump that is available?
The quad dump includes the schema:
$ bzgrep $'/type/object/type\t/type/type' freebase-datadump-quadruples.tsv.bz2
/m/01xxrl4 /type/object/type /type/type
/m/01xxwk6 /type/object/type /type/type
/m/01y1zzx /type/object/type /type/type
/m/021_hyv /type/object/type /type/type
/m/0252jv4 /type/object/type /type/type
/m/0252jw2 /type/object/type /type/type
/m/0252jx0 /type/object/type /type/type
/m/025dnqw /type/object/type /type/type
/m/0290pj9 /type/object/type /type/type
It's available from http://download.freebase.com/datadumps/latest/freebase-datadump-quadruples.tsv.bz2
Related
i have created a struct and it contains two time.Time formatted fields, named with json tags: start_time and end_time.
type MyStruct struct {
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
}
when i'm trying to send a PUT request over HTTP using gin framework to update those values, the time format which i'm sending, changes in sent struct.
what i'm sending:
curl -X PUT -H 'Content-Type: application/json'
http://my_address -d '{
"start_time": "2021-04-27T22:24:31Z",
"end_time": "2021-11-01T22:24:31Z"
}'
what it receives:
start_time="2021-04-27 22:24:31 +0000 UTC",
end_time="2021-11-01 22:24:31 +0000 UTC",
in the other hand,
i'm saving the struct in a couchbase and as returning value of query, i'm sending back the document(my struct):
my query:
Update BucketName as e
set start_time="2021-04-27 22:24:31 +0000 UTC",
end_time="2021-11-01 22:24:31 +0000 UTC" where ( my document equality condition)
returning e
and it executes with no errors.
when i'm trying to read the returned struct,
my code to reading it:
var s domain.MyStructSample //
err = result.One(&s)
if err != nil {
if err == gocb.ErrNoResult {
return nil, errors.New("there is no result")
}
logger.ZSLogger.Errorf("error on update one item from my struct with error :%s", err)
return nil, err
}
gocb generates errors on those time items and here is the error:
"message":"error on update one item from my struct with error :parsing time \"\"2021-11-01 22:24:31 +0000 UTC\"\" as \"\"2006-01-02T15:04:05Z07:00\"\": cannot parse \" 22:24:31 +0000 UTC\"\" as \"T\""}
by the way, as i said, update is done with no errors ( query executes with no errors).
so what should i do with it ?
How did you generate this query:
Update BucketName as e
set start_time="2021-04-27 22:24:31 +0000 UTC",
end_time="2021-11-01 22:24:31 +0000 UTC" where ( my document equality condition)
returning e
As the error says, time data stored in couchbase should be in format RFC3339 (2006-01-02T15:04:05Z07:00) instead of the default 2006-01-02 15:04:05 -0700 MST, so maybe you should insert data with query:
Update BucketName as e
set start_time="2021-04-27T22:24:31Z07:00",
end_time="2021-11-01T22:24:31Z07:00" where ( my document equality condition)
returning e
If you have problem formatting time, read the doc https://golang.cafe/blog/golang-time-format-example.html
And, as #MrFuppes commented, if you need to customize JSON output format, read this How to format timestamp in outgoing JSON
I have an xml data file where user has opened an account and in some cases the account has been terminated. The data does not list the value when account has not been terminated, which makes it very difficult to extract the information.
Here is the reproducible example (where only user 1 and 3 have had their account terminated):
library(XML)
my_xml <- xmlParse('<accounts>
<user>
<id>1</id>
<start>2015-01-01</start>
<termination>2015-01-21</termination>
</user>
<user>
<id>2</id>
<start>2015-01-01</start>
</user>
<user>
<id>3</id>
<start>2015-02-01</start>
<termination>2015-04-21</termination>
</user>
<user>
<id>4</id>
<start>2015-03-01</start>
</user>
<user>
<id>5</id>
<start>2015-04-01</start>
</user>
</accounts>')
To create a data.frame I've tried using sapply however due to it not returning NA when user does not have a termination value, the code produces an error: arguments imply differing number of rows: 5, 2
accounts <- data.frame(id=sapply(my_xml["//user//id"], xmlValue),
start=sapply(my_xml["//user//start"], xmlValue),
termination=sapply(my_xml["//user//termination"], xmlValue)
)
Any suggestions on how to solve this problem ?
I prefer to use the xml2 package over the XML package, I find the syntax easier to use.
This is a straight forward problem. Find all of the user nodes and then parse out the id and termination nodes. With xml2, the xml_find_first function will return NA even if the node is not found.
library(xml2)
my_xml <- read_xml('<accounts>
<user>
<id>1</id>
<start>2015-01-01</start>
<termination>2015-01-21</termination>
</user>
<user>
<id>2</id>
<start>2015-01-01</start>
</user>
<user>
<id>3</id>
<start>2015-02-01</start>
<termination>2015-04-21</termination>
</user>
<user>
<id>4</id>
<start>2015-03-01</start>
</user>
<user>
<id>5</id>
<start>2015-04-01</start>
</user>
</accounts>')
usernodes<-xml_find_all(my_xml, ".//user")
ids<-xml_text(xml_find_first(usernodes, ".//id") )
terms<-xml_text(xml_find_first(usernodes, ".//termination"))
answer<-data.frame(ids, terms)
I managed to find a solution from XPath in R: return NA if node is missing
accounts <- data.frame(id=sapply(my_xml["//user//id"], xmlValue),
start=sapply(my_xml["//user//start"], xmlValue),
termination=sapply(xpathApply(my_xml, "//user",
function(x){
if("termination" %in% names(x))
xmlValue(x[["termination"]])
else NA}), function(x) x))
I've slowly progressing through my serialport tcl app but hit another wall.
I want to create an array of boolean values to iterate in a for loop.
In the for loop, DTR will send a serial output.
Below I have the following code:
set rs232 [open COM3: r]
fconfigure $rs232 -ttycontrol {DTR 0}
array set values {
0 0
1 1
}
set n [array size values]
set x 0
for {set a 0} {$a <=15} {incr a} {
fconfigure $rs232 -ttycontrol {DTR $values(0)}
wait 1000
fconfigure $rs232 -ttycontrol {DTR $values(1)}
wait 1000
}
I run it and I get the error:
expected boolean value but got "$values(0)"
Can anyone tell me why this is and how do I fix it?
This invocation:
fconfigure $rs232 -ttycontrol {DTR $values(0)}
passes the value "DTR $values(0)" for -ttycontrol to fconfigure. The invocation
fconfigure $rs232 -ttycontrol [list DTR $values(0)]
passes "DTR 0".
The braces prevent substitution of the variable, but the invocation of list enforces it.
Alternatively, you could use one of
fconfigure $rs232 -ttycontrol "DTR $values(0)"
fconfigure $rs232 -ttycontrol [subst {DTR $values(0)}]
Below is my sample XML
<catalog>
<book>
<author>Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
<storeno>123</storeno>
</book>
<book>
<author>Ralls, Kim</author>
<title>Rain Fantasy</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former</description>
<storeno>123</storeno>
</book>
<book>
<author>zxcv</author>
<title>Maeve</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology</description>
<storeno>123</storeno>
</book>
<book>
<author>zxcv</author>
<title>Legacy</title>
<genre>Fiction</genre>
<price>5.95</price>
<publish_date>2001-03-10</publish_date>
<description>In post-apocalypse</description>
<storeno>123</storeno>
</book>
<book>
<author>Corets, Eva</author>
<title>The</title>
<genre>Fiction</genre>
<price>5.95</price>
<publish_date>2001-09-10</publish_date>
<description>The two daughters</description>
<storeno>123</storeno>
</book>
<book>
<author>Horror</author>
<title>Horror</title>
<genre>Horror</genre>
<price>4.95</price>
<publish_date>2000-09-02</publish_date>
<description>When abc meets xyz</description>
<storeno>123</storeno>
</book>
<book>
<author>Knorr, Stefan</author>
<title>Creepy Crawlies</title>
<genre>Horror</genre>
<price>4.95</price>
<publish_date>2000-12-06</publish_date>
<description>An anthology of horror stories about roaches,
centipedes, scorpions and other insects.</description>
<storeno>123</storeno>
</book>
<book>
<author>O'Brien, Tim</author>
<title>kids ganes</title>
<genre>story</genre>
<price>36.95</price>
<publish_date>2000-12-09</publish_date>
<description>Microsoft's .NET initiative is explored in
detail in this deep programmer's reference.</description>
<storeno>123</storeno>
</book>
<book>
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>computer</genre>
<price>36.95</price>
<publish_date>2000-12-01</publish_date>
<description>The abc</description>
<storeno>123</storeno>
</book>
<book>
<author>Galos, Mike</author>
<title>Visual Studio 7: A Comprehensive Guide</title>
<genre>story</genre>
<price>49.95</price>
<publish_date>2001-04-16</publish_date>
<description>Microsoft Visual Studio</description>
<storeno>123</storeno>
</book>
</catalog>
and I need an XQuery that returns
<titles>
need the first instance of the title where the genre is “Fantasy”
need all the titles concatenated where the genre is “Computer”
need all the titles concatenated where the genre is “Fiction”
need the first instance of the title where the genre is “Story”
</ titles >
example:( Rain Fantasy, XML Developer's Guide………………, Legacy……………….., kids ganes)
Note: the case can be ignored in the above for comparison.
Here is what we are trying
<Titles>
let $fan := $catalog /book[genre = ‘Fantasy’][1]/title
let $stry := $catalog /book[genre = ‘Story’][1]/title
for $comp in $catalog /book[genre ='Computer']/title
return concat($comp, “”)
for $fict in $catalog /book[genre ='Fiction']/title
return concat($fict, “”)
concat($fan, $comp, $fict, $stry)
</Titles>
we are facing issues in multiple for loops implementation.
Any help is really appreciated.
Thanks in advance
From the question and the comments you seem to want something like this:
<Titles>
{
for $genre in distinct-values($catalog/book/genre)
let $books := $catalog/book[genre=$genre]
let $retval := if($genre=("Fantasy","Story")) then $books[1]/title else $books/title
return data($retval)
}
</Titles>
With your input, the result this gives is:
<Titles>XML Developer's Guide Rain Fantasy Legacy The Horror Creepy Crawlies kids ganes Visual Studio 7: A Comprehensive Guide MSXML3: A Comprehensive Guide</Titles>
My gut tells me you probably don't want the data() part though. Without it you get:
<Titles>
<title>XML Developer's Guide</title>
<title>Rain Fantasy</title>
<title>Legacy</title>
<title>The</title>
<title>Horror</title>
<title>Creepy Crawlies</title>
<title>kids ganes</title>
<title>Visual Studio 7: A Comprehensive Guide</title>
<title>MSXML3: A Comprehensive Guide</title>
</Titles>
I have this DTD
<?xml version="1.0" encoding="utf-8"?>
<!ELEMENT MusicCatalog (Artist*,Album*,Genre+,Company*,Country*)>
<!ELEMENT Artist (Name)>
<!ELEMENT Name (FirstName,MiddleName*,LastName?)>
<!ELEMENT FirstName (#PCDATA)>
<!ELEMENT MiddleName (#PCDATA)>
<!ELEMENT LastName (#PCDATA)>
<!ATTLIST Artist ArtistID ID #REQUIRED
countryID IDREF #REQUIRED>
<!ELEMENT Album (Title,Price,Year)>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Price (#PCDATA)>
<!ELEMENT Year (#PCDATA)>
<!ATTLIST Album AlbumID ID #REQUIRED
ArtistID IDREF #REQUIRED
CompanyID IDREF #REQUIRED
GenreName IDREFS #REQUIRED >
<!ELEMENT Company (#PCDATA)>
<!ATTLIST Company CompanyID ID #REQUIRED>
<!ELEMENT Genre EMPTY>
<!ATTLIST Genre GenreName ID #REQUIRED>
<!ELEMENT Country (#PCDATA)>
<!ATTLIST Country countryID ID #REQUIRED>
and I Have this basic XML
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE MusicCatalog SYSTEM "Refined_DTD_For_catalog.dtd">
<MusicCatalog>
<Artist ArtistID="Ar_0000" countryID="US">
<Name>
<FirstName>Katey </FirstName>
<LastName>Berry</LastName>
</Name>
</Artist>
<Artist ArtistID="Ar_0001" countryID="US">
<Name>
<FirstName>Justine </FirstName>
<LastName>Temrilke</LastName>
</Name>
</Artist>
<Album AlbumID="AL_0000" ArtistID="Ar_0000" CompanyID="C_3" GenreName="Pop HipHop R_and_B">
<Title>Calfornia Girls</Title>
<Price>12</Price>
<Year>2012</Year>
</Album>
<Album AlbumID="AL_0001" ArtistID="Ar_0000" CompanyID="C_1" GenreName="Pop HipHop R_and_B">
<Title>Confessions</Title>
<Price>9</Price>
<Year>2008</Year>
</Album>
<Album AlbumID="AL_0002" ArtistID="Ar_0000" CompanyID="C_10" GenreName="Pop HipHop R_and_B">
<Title>Roar</Title>
<Price>13</Price>
<Year>2014</Year>
</Album>
<Album AlbumID="AL_0003" ArtistID="Ar_0000" CompanyID="C_4" GenreName=" HipHop R_and_B">
<Title>Teenge Dream</Title>
<Price>11</Price>
<Year>2010</Year>
</Album>
<Album AlbumID="AL_0004" ArtistID="Ar_0001" CompanyID="C_4" GenreName="HipHop R_and_B">
<Title>Future of sex</Title>
<Price>8</Price>
<Year>2007</Year>
</Album>
<Album AlbumID="AL_0005" ArtistID="Ar_0001" CompanyID="C_5" GenreName="HipHop">
<Title>Mirros</Title>
<Price>8</Price>
<Year>2013</Year>
</Album>
<Album AlbumID="AL_0006" ArtistID="Ar_0001" CompanyID="C_5" GenreName="Electro">
<Title>Holly Grail</Title>
<Price>9</Price>
<Year>2014</Year>
</Album>
<Album AlbumID="AL_0007" ArtistID="Ar_0001" CompanyID="C_6" GenreName="HipHop Electro">
<Title>Give it to me</Title>
<Price>5</Price>
<Year>2005</Year>
</Album>
<Genre GenreName="Rap"/>
<Genre GenreName="Country"/>
<Genre GenreName="R_and_B"/>
<Genre GenreName="HipHop"/>
<Genre GenreName="House"/>
<Genre GenreName="Pop"/>
<Genre GenreName="Electro"/>
<Genre GenreName="Blues"/>
<Genre GenreName="Punck"/>
<Genre GenreName="Rock"/>
<Genre GenreName="Metal"/>
<Genre GenreName="Alternative_Rock"/>
<Company CompanyID="C_1">
CBS Records
</Company>
<Company CompanyID="C_2">
RCA
</Company>
<Company CompanyID="C_3">
WEA
</Company>
<Company CompanyID="C_4">
Cloumbia
</Company>
<Company CompanyID="C_5">
Virgin Records
</Company>
<Company CompanyID="C_6">
Pickwick
</Company>
<Company CompanyID="C_7">
Atlantic
</Company>
<Company CompanyID="C_8">
Mega
</Company>
<Company CompanyID="C_9">
Grammy
</Company>
<Company CompanyID="C_10">
Wordo
</Company>
<Company CompanyID="C_11">
Fox
</Company>
<Country countryID="US">
United State
</Country>
<Country countryID="UK">
United Kingdom
</Country>
<Country countryID="FR">
France
</Country>
<Country countryID="GR">
Germany
</Country>
<Country countryID="ME">
Mexico
</Country>
<Country countryID="SP">
Spain
</Country>
<Country countryID="JP">
Japneas
</Country>
</MusicCatalog>
My problem with Xquery is I'm not getting what the expected result, in this query I'm trying to get companies name, create element with name and indie it to get the all albums titles but I'm getting only the company id, I tried to solve with many queries but most of it don't work
for $dc in distinct-values( //Album/#CompanyID )
return element {string ($dc)} {
for $j in //Album[#CompanyID = $dc] return $j/Title
}
This another try
for $i in distinct-values(//MusicCatalog/Album/#CompanyID)
return
if(compare($i,//MusicCatalog/Company/#CompanyID))
then "element {string(//MusicCatalog/Company)}"
{
for $j in //MusicCatalog/Album[#CompanyID eq $i] return $j/Title
}
}
I getting this
<c_3>
<title>Calfornia Girls</title>
<title>Roar/title>
</c_3>
while I want to get
<WEA>
<title>Calfornia Girls</title>
<title>Roar/title>
</WEA>
another problem is with getting genre albums beacuse it's mutlipe IDrefs .
If you want the company name as element name, you should not pass the id, but the name. I.e. search the name with another path expression:
for $i in distinct-values(//MusicCatalog/Album/#CompanyID)
return
element {translate(normalize-space(//MusicCatalog/Company[#CompanyID eq $i]), " ", "_")}
{
for $j in //MusicCatalog/Album[#CompanyID eq $i]
return $j/Title
}
}