How to parse text to cdt values

Hi All,

I have a text where user will be giving the information in text format , any ideas hot to parse that data to cdt ?? 

Like usermight say , I am bhargavi from India .. from this need to extract as name : bhargavi , country : india something like this .

Thanks,

Bhargavi P.

  Discussion posts and replies are publicly visible

Parents
  • Hi

    This is similar to implementing AI and AI is all about eliminating unlike choices. Having said that and referring to what mentioned, I have drafted this sample code. This is not the ideal way to implement this but is certainly one of the closest ways to get there. Hopefully, it gives you an idea in sort of which direction to go for.

     

    with(
      local!countries: {"India", "UK","USA"},
    
      local!userText_words:split(ri!userTxt, " "),
      local!articles: {"a", "an", "the"},
      local!prepositions: {"of","from","on","in", "to", "within","with","at"},
      local!places: index(local!userText_words, wherecontains(local!countries,local!userText_words),{}),
      local!pronouns: {"I", "We", "She", "He", "They", "him", "her", "their", "his"},
      local!verbs: {"am","is","are"},
    
      local!names: difference(local!userText_words,{local!pronouns,local!prepositions,local!countries,
      local!articles, local!verbs}),
      local!cdt: 'type!{urn:com:appian:types}candidatureDetails'(),
      a!sectionLayout(
        label:"",
        contents: {
          a!textField(
            label:"Enter text",
            value: ri!userTxt,
            saveInto:ri!userTxt
          ),
          
          a!columnsLayout(
            columns:{
              a!columnLayout(
                contents: {
                  a!checkboxField(
                    label:"Names",
                    choiceLabels: local!names,
                    choiceValues: local!names,
                    value:local!cdt.name,
                    saveInto:local!cdt.name,
                    showWhen: not(rule!APN_isEmpty(local!names))
                  )
                }
              ),
              a!columnLayout(
                contents: {
                  a!checkboxField(
                    label:"Countries",
                    choiceLabels: local!places,
                    choiceValues: local!places,
                    value:local!cdt.communicationAddress,
                    saveInto:local!cdt.communicationAddress,
                    showWhen: not(rule!APN_isEmpty(local!places))
                  )
                }
              )
            },
            showWhen: not(rule!APN_isEmpty(ri!userTxt))
          )
        }
      )
    )

Reply
  • Hi

    This is similar to implementing AI and AI is all about eliminating unlike choices. Having said that and referring to what mentioned, I have drafted this sample code. This is not the ideal way to implement this but is certainly one of the closest ways to get there. Hopefully, it gives you an idea in sort of which direction to go for.

     

    with(
      local!countries: {"India", "UK","USA"},
    
      local!userText_words:split(ri!userTxt, " "),
      local!articles: {"a", "an", "the"},
      local!prepositions: {"of","from","on","in", "to", "within","with","at"},
      local!places: index(local!userText_words, wherecontains(local!countries,local!userText_words),{}),
      local!pronouns: {"I", "We", "She", "He", "They", "him", "her", "their", "his"},
      local!verbs: {"am","is","are"},
    
      local!names: difference(local!userText_words,{local!pronouns,local!prepositions,local!countries,
      local!articles, local!verbs}),
      local!cdt: 'type!{urn:com:appian:types}candidatureDetails'(),
      a!sectionLayout(
        label:"",
        contents: {
          a!textField(
            label:"Enter text",
            value: ri!userTxt,
            saveInto:ri!userTxt
          ),
          
          a!columnsLayout(
            columns:{
              a!columnLayout(
                contents: {
                  a!checkboxField(
                    label:"Names",
                    choiceLabels: local!names,
                    choiceValues: local!names,
                    value:local!cdt.name,
                    saveInto:local!cdt.name,
                    showWhen: not(rule!APN_isEmpty(local!names))
                  )
                }
              ),
              a!columnLayout(
                contents: {
                  a!checkboxField(
                    label:"Countries",
                    choiceLabels: local!places,
                    choiceValues: local!places,
                    value:local!cdt.communicationAddress,
                    saveInto:local!cdt.communicationAddress,
                    showWhen: not(rule!APN_isEmpty(local!places))
                  )
                }
              )
            },
            showWhen: not(rule!APN_isEmpty(ri!userTxt))
          )
        }
      )
    )

Children
No Data