Data Technology Implementation

Data Technology Implementation

If this is the first article you read, we recommend that you first review the introduction of details about what Mandy is and What is technology. This will allow you to supplement the PubChem programming code to use the Mandy program – the Smart Companion. On the other hand, if you are just trying to use the PubChem library API then you can continue reading.

artificial intelligence with Technology Implementation

Mandy – The Intelligent Companion is an AI tool that was programmed in python and that you can use to identify situations in which chemical compounds are involved. is the technology that makes you identify the intention of a user when receiving a question or comment at the start of the application.

As you can verify, technology identifies when users are interested in doing things that require them to know about the chemical compatibility, storage intention and information intention of a chemical compound.

Specifically the app identifies the following intents:

• Chemical compatibility search intention: The user wants to know about the chemical compatibility of a specific chemical compound. 
• Storage intention: The user needs to store a chemical compound or product that contains a specific chemical compound. 
• Information search intention: The user wants to know about the properties and characteristics of a chemical compound.

Create a Account

First you need to create a account so that you get an access token for your application. Type in any browser with access to the internet and follow these steps:

• Click on sign up
• Submit an email, username and password
• Verify the email registered
• Click on the button create a New App

The variable access_token_wit must contain the token that you generated from in you account so that you can find this variable at the beginning of the programming code. You will find some code like this one:


Chemical compound and Intention Identification

Train your robot with data

Once you obtained you wit access token, you can start training your robot to identify chemical compounds and intentions from the users’ message. You can train your robot on the website or use the API that is provided so that you automate the training process. Here you can see how to implement the requests so that you submit utterances, intents, etc.

Utterances API Programming Code

Intents API programming Code

The application uses the following python libraries that allow you to get the right information for the user: it • Wit: this library identifies the user intention as something is mentioned on the input box of the application • json: this library is used to handle data receive from the response of the different APIs integrated in the application

This section contains a main function called wit_request that receives the question from the user and the token that was generated at Depth, extract and json_extract are two subfunctions that are used to extract the data received from so that you obtain only the chemicals’ names and the intention from the user’s message.

wit_request Main Function

def wit_request(question,access_token_wit):

client = Wit(access_token=access_token_wit)


def depth(data):
    if "entities" in data:
        return 1 +  max([0] + list(map(depth, data['entities'])))      
        return 1

def json_extract(obj,key):
    def extract(obj,arr,key):
        if isinstance(obj,dict):
            for k,v in obj.items():
                if isinstance(v,(dict,list)):
                elif v==key:
                    if obj not in arr:
        elif isinstance(obj,list):
            for item in obj:
        return (arr)
    return values
#get intents
#extract chemicals that found
for q in range(number_chemicals):

return (chemicals,intent)

Json_Extract and Subfunctions

These functions are used to obtain chemicals’ names and intents from the response that is saved in the data variable. Essentially, these functions receive an object which can be a list, array or dictionary and parse the data of those objects until the values of the intents key and chemical_subtance key are reached after iterating over the different objects contained in the json response.

We suggest you consult the flow diagram of Mandy the Intelligent Companion so that you understand the stages and functions that are activated at a certain moment in the process of transcribing the audio of your videos. The youtube module implementation phase is the final phase so you can check the first phase (technology implementation) and second (PubChem technology implementation).