module-nlp
v1.0.6
Published
This module provides the natural language understanding functions.
Downloads
1
Readme
module-nlp
Features
- Machine Comprehension
- Textual Entailment
- Semantic Role Labeling
- Named Entity Recognition
- Coreference Resolution
Machine Comprehension
machine_comprehension(query)
- Input:
console.log(package.machine_comprehension( {"passage":"Robotics is an interdisciplinary branch of engineering and science that includes mechanical engineering, electrical engineering, computer science, and others. Robotics deals with the design, construction, operation, and use of robots, as well as computer systems for their control, sensory feedback, and information processing. These technologies are used to develop machines that can substitute for humans. Robots can be used in any situation and for any purpose, but today many are used in dangerous environments (including bomb detection and de-activation), manufacturing processes, or where humans cannot survive. Robots can take on any form but some are made to resemble humans in appearance. This is said to help in the acceptance of a robot in certain replicative behaviors usually performed by people. Such robots attempt to replicate walking, lifting, speech, cognition, and basically anything a human can do.","question":"What do robots that resemble humans attempt to do?"} ))
- Output:
{ "best_span": [ 147, 154 ], "best_span_str": "replicate walking, lifting, speech, cognition", "span_end_logits": [ -6.517852306365967, -12.051702499389648, -12.485725402832031, ..... }
Textual Entailment
textual_entailment(query)
- Input:
console.log(package.semantic_role_labeling( {"premise":"Two women are wandering along the shore drinking iced tea.","hypothesis":"Two women are sitting on a blanket near some rocks talking about politics."} ))
- Output:
{"label_logits":[-3.6113696098,2.6817588806,1.1695688963],"label_probs":[0.0015127246,0.81814605,0.1803412586],"slug":"MTU0NjQ="}
Semantic Role Labeling
semantic_role_labeling(query)
- Input:
console.log(package.semantic_role_labeling( {"sentence":"However, voters decided that if the stadium was such a good idea someone would build it himself, and rejected it 59% to 41%."} ))
- Output:
{ "tokens": [ "However", ",", "voters", "decided", "that", "if", "the", "stadium", "was", "such", "a", "good", "idea", "someone" ] }
Named Entity Recognition
named_entity_recognition(query)
- Input:
console.log(package.named_entity_recognition( {"sentence":"Michael Jordan is a professor at Berkeley."} ))
- Output:
{ "logits": [ [ 0.6069703102111816, -1.9964487552642822, 9.776033401489258, -3.4721059799194336, -0.1944570243358612, -3.486645460128784, 1.6684856414794922, -4.359092712402344, 3.2526683807373047, -2.0060856342315674, 2.8877902030944824, -5.399940490722656, -1.498845100402832, -5.677943706512451, -4.222471714019775, 1.198972463607788, -2.671220064163208 ], [ 0.29961785674095154, 3.553903102874756 ]] }
Coreference Resolution
coreference_resolution(query)
- Input:
console.log(package.named_entity_recognition( {"document":"We 're not going to skimp on quality , but we are very focused to make next year . The only problem is that some of the fabrics are wearing out - since I was a newbie I skimped on some of the fabric and the poor quality ones are developing holes . For some , an awareness of this exit strategy permeates the enterprise , allowing them to skimp on the niceties they would more or less have to extend toward a person they were likely to meet again ."} ))
- Output:
{"document":["We","'re","not","going","to","skimp","on","quality",",","but","we","are","very","focused","to","make","next","year",".","The","only","problem","is","that","some","of","the","fabrics","are","wearing","out","-","since","I","was","a","newbie","I","skimped","on","some","of","the","fabric","and","the","poor","quality","ones","are","developing","holes",".","For","some",",","an","awareness","of","this","exit","strategy","permeates","the","enterprise",",","allowing","them","to","skimp","on","the","niceties","they","would","more","or","less","have","to","extend","toward","a","person","they","were","likely","to","meet","again","."],"clusters":[[[0,0],[10,10]],[[33,33]]]}