Prompt Resource

ThemeTableJSON

Source Notebook

Tabulates in JSON themes found in text

 

Examples

Here we tabulate UN Human Rights document:

In[1]:=
tblHR = LLMResourceFunction["ThemeTableJSON"][
  ExampleData[{"Text", "UNHumanRightsEnglish"}]]
Out[1]=

Here we use the second argument to specify that the text is a theatrical play and the content descriptions are no more than 20 words:

In[2]:=
tblHamlet = LLMResourceFunction["ThemeTableJSON"][
  ExampleData[{"Text", "Hamlet"}], "theatrical play", 20]
Out[2]=

Scope (3) 

The following function converts wider range of LLM results obtained by requests to generate JSON code:

In[3]:=
Clear[FromJSON];
FromJSON[t_String] := ImportString[
   FromCharacterCode@
    ToCharacterCode[
     StringReplace[
      t, {StartOfString ~~ "```json", "```" ~~ EndOfString} -> ""], "UTF-8"], "RawJSON"];

Here we convert the LLM Human Rights result into a table:

In[4]:=
ResourceFunction["GridTableForm"]@Dataset[tblHR // FromJSON]
Out[4]=

Here we convert the "Hamlet" LLM result into a table:

In[5]:=
ResourceFunction["GridTableForm"]@Dataset[tblHamlet // FromJSON]
Out[5]=

Possible Issues

For most articles only models with larger limits of input tokens can applied. For example, (current) OpenAI's ChatGPT model "gpt-4-turbo-preview" that allows 128K input tokens.

Source Metadata

Publisher Information