Example #1
0
        static List <TripleTerm> ExtractTriple(string content)
        {
            List <TripleTerm> result = new List <TripleTerm>();

            edu.stanford.nlp.simple.Document doc = new edu.stanford.nlp.simple.Document(content);
            var list = doc.sentences();

            for (int i = Variable.VariableZero; i < list.size(); i++)
            {
                edu.stanford.nlp.simple.Sentence sentence = (edu.stanford.nlp.simple.Sentence)list.get(i);
                var tripleList = sentence.openieTriples();
                for (int j = Variable.VariableZero; j < tripleList.size(); j++)
                {
                    var            tripleListArray = tripleList.toArray();
                    RelationTriple relationTriple  = (RelationTriple)tripleListArray[j];
                    var            currentTriple   = new TripleTerm(
                        relationTriple.subjectGloss(),
                        relationTriple.relationGloss(),
                        relationTriple.objectGloss());
                    result.Add(currentTriple);
                }
            }
            return(result);
        }
Example #2
0
 /// <summary>
 /// Create a new sentence directly from the given CoreNLP Sentence isntance.
 /// </summary>
 /// <param name="nlpSentence">The CoreNLP Sentence.</param>
 internal Sentence(edu.stanford.nlp.simple.Sentence nlpSentence)
 {
     this.nlpSentence = nlpSentence;
 }