Wolfram Language

Improved Machine Learning

Create a Text Search Tool Using Feature Extraction

Train a feature extractor from sentences of Alice in Wonderland:

In[1]:=
Click for copyable input
alice = ExampleData[{"Text", "AliceInWonderland"}]; sentences = TextSentences[alice]; fe = FeatureExtraction[sentences]
Out[1]=

Generate a NearestFunction on the extracted features of the dataset.

In[2]:=
Click for copyable input
nf = Nearest[fe[sentences] -> Automatic]
Out[2]=

Construct a function that displays the nearest sentence in Alice in Wonderland and use it on a few sentences.

In[3]:=
Click for copyable input
nearestalice = sentences[[First@nf[fe[#]]]] &;
In[4]:=
Click for copyable input
nearestalice["Alice and the Rabbit"]
Out[4]=
In[5]:=
Click for copyable input
nearestalice["Off her head"]
Out[5]=

Related Examples

de es fr ja ko pt-br ru zh