4

I'd like to query, for example, the Entity["MusicWork"] data for something like "all music works whose names contain the word 'Funk'". Or even "plot a date histogram by year of the number of works whose name contains the word 'Funk', as a fraction of the total number of works".

I can easily get all the works with some exact name:

EntityList[
  Entity["MusicWork", {"Name" -> "Jump"}]]

I can query for works released within some time interval:

EntityList[
  Entity["MusicWork", {"FirstRecordingDate" -> DateObject[{2006}]}]]

But I'd like to query for a pattern in the "Name" property, but I'm unable to glean from the documentation what type of expression I can use here.

Apocalisp
  • 141
  • 4
  • I you want to edit your question a lot, please do it in a separate paragraph. We don't want to end up with a question and a bunch of unrelated answers. – paw Oct 28 '15 at 17:13
  • I edited the question because it got two answers about date intervals. While that's helpful, it's not really what the question is about. – Apocalisp Oct 28 '15 at 17:16

2 Answers2

1

Interval needs { and }:

In[1]:= EntityList[
  EntityClass[
   "MusicWork", {"FirstRecordingDate" -> 
     Interval[{DateObject[{2006, 1}], 
       DateObject[{2006, 12}]}]}]] // Length

Out[1]= 3951

Implicitly defined entity classes do not support string matching inside property values.

Toni
  • 11
  • 1
0

You don't need to use Interval here, DateObject[{2006}] is a much better option here.

music2006 = 
  EntityList[
   Entity["MusicWork", {"FirstRecordingDate" -> DateObject[{2006}]}]];

You can filter this list of entities for works that contain the word "funk" using

Select[music2006, StringMatchQ[EntityValue[#, "Name"], ___ ~~ "funk" ~~ ___] &]
paw
  • 5,650
  • 23
  • 31