具有相同谓词的主语和动作

时间:2017-02-03 19:06:23

标签: sparql rdf rdf-xml

我有RDF / XML格式的RDF文件。 RDF文件描述了句子的subjectactionobject,我想提取它们。 subjectobject值在aapi:text,中描述,但object值由aapi:name描述。我的问题是我无法区分句子的subjectaction,因为它们具有相同的谓词并且它们不保留顺序。

这是我的代码:

FileManager.get().addLocatorClassLoader(MainSparql.class.getClassLoader());
    Model model= FileManager.get().loadModel("c:/users/bistika/workspace/test3/src/com/sparql/test.rdf");


    String querystrng="PREFIX aapi: <http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#> " +
            "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +

            "SELECT  ?id (SAMPLE(?N) AS ?subject)(SAMPLE(?N2) AS ?action)(SAMPLE(?ob) AS ?object) WHERE {" +        
            "?id aapi:Text ?N , ?N2 ; aapi:Name ?ob."+  
            "FILTER( ?N != ?N2 )." +
            "}GROUP BY ?id";
}

输出 screenshot of the output

文件部分

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:aapi="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
     xml:base="http://rdf.alchemyapi.com/rdf/v1/r/response.rdf">
<rdf:Description rdf:ID="db844b19ba6b2a6bc2f4e1ea706f63335a63955cf">
    <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#DocInfo"/>
    <aapi:ResultStatus>OK</aapi:ResultStatus>
    <aapi:Usage>By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html</aapi:Usage>
    <aapi:URL>http://www.confluence-denver.com/innovationnews/alchemyapi_booming.aspx/</aapi:URL>
    <aapi:Language>english</aapi:Language>
</rdf:Description>
<rdf:Description rdf:ID="db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_1">
    <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationOccurrence"/>
    <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
    <aapi:RelationSentence> In 2009, Elliot Turner launched AlchemyAPI to process the written word, with all of its quirks and nuances, and got immediate traction.</aapi:RelationSentence>
    <aapi:RelationSubject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_1">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationSubject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>Elliot Turner</aapi:Text>
        </rdf:Description>
    </aapi:RelationSubject>
    <aapi:RelationAction>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_1">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationAction"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>to process</aapi:Text>
            <aapi:LemmatizedText>to process</aapi:LemmatizedText>
            <aapi:VerbText>process</aapi:VerbText>
            <aapi:VerbTense>future</aapi:VerbTense>
        </rdf:Description>
    </aapi:RelationAction>
    <aapi:RelationObject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_1">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationObject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Name>the written word, with all of its quirks and nuances</aapi:Name>
        </rdf:Description>
    </aapi:RelationObject>
</rdf:Description>
<rdf:Description rdf:ID="db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_2">
    <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationOccurrence"/>
    <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
    <aapi:RelationSentence> In 2009, Elliot Turner launched AlchemyAPI to process the written word, with all of its quirks and nuances, and got immediate traction.</aapi:RelationSentence>
    <aapi:RelationSubject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_2">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationSubject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>immediate traction</aapi:Text>
        </rdf:Description>
    </aapi:RelationSubject>
    <aapi:RelationAction>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_2">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationAction"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>got</aapi:Text>
            <aapi:LemmatizedText>get</aapi:LemmatizedText>
            <aapi:VerbText>get</aapi:VerbText>
            <aapi:VerbTense>past</aapi:VerbTense>
        </rdf:Description>
    </aapi:RelationAction>
</rdf:Description>
<rdf:Description rdf:ID="db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_3">
    <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationOccurrence"/>
    <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
    <aapi:RelationSentence> That first month, the company's eponymous language-analysis API processed 500,000 transactions.</aapi:RelationSentence>
    <aapi:RelationSubject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_3">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationSubject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>the company's eponymous language-analysis API</aapi:Text>
        </rdf:Description>
    </aapi:RelationSubject>
    <aapi:RelationAction>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_3">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationAction"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>processed</aapi:Text>
            <aapi:LemmatizedText>process</aapi:LemmatizedText>
            <aapi:VerbText>process</aapi:VerbText>
            <aapi:VerbTense>past</aapi:VerbTense>
        </rdf:Description>
    </aapi:RelationAction>
    <aapi:RelationObject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_3">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationObject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Name>500,000 transactions</aapi:Name>
        </rdf:Description>
    </aapi:RelationObject>
</rdf:Description>
<rdf:Description rdf:ID="db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_4">
    <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationOccurrence"/>
    <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
    <aapi:RelationSentence> Today it's processing three billion transactions a month, or about 1,200 a second.</aapi:RelationSentence>
    <aapi:RelationSubject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_4">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationSubject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>it</aapi:Text>
        </rdf:Description>
    </aapi:RelationSubject>
    <aapi:RelationAction>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_4">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationAction"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>has</aapi:Text>
            <aapi:LemmatizedText>has</aapi:LemmatizedText>
            <aapi:VerbText>has</aapi:VerbText>
            <aapi:VerbTense>present</aapi:VerbTense>
        </rdf:Description>
    </aapi:RelationAction>
    <aapi:RelationObject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_4">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationObject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Name>processing three billion transactions a month, or about 1,200 a second</aapi:Name>
        </rdf:Description>
    </aapi:RelationObject>
</rdf:Description>
<rdf:Description rdf:ID="db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_5">
    <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationOccurrence"/>
    <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
    <aapi:RelationSentence> Today it's processing three billion transactions a month, or about 1,200 a second.</aapi:RelationSentence>
    <aapi:RelationSubject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_5">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationSubject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>it</aapi:Text>
        </rdf:Description>
    </aapi:RelationSubject>
    <aapi:RelationAction>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_5">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationAction"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>processing</aapi:Text>
            <aapi:LemmatizedText>process</aapi:LemmatizedText>
            <aapi:VerbText>process</aapi:VerbText>
            <aapi:VerbTense>present</aapi:VerbTense>
        </rdf:Description>
    </aapi:RelationAction>
    <aapi:RelationObject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_5">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationObject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Name>three billion transactions a month, or about 1,200 a second</aapi:Name>
        </rdf:Description>
    </aapi:RelationObject>
</rdf:Description>
<rdf:Description rdf:ID="db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_6">
    <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationOccurrence"/>
    <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
    <aapi:RelationSentence> “That's a growth rate of 6,000 times over three years,” touts Turner.</aapi:RelationSentence>
    <aapi:RelationSubject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_6">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationSubject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>That</aapi:Text>
        </rdf:Description>
    </aapi:RelationSubject>
    <aapi:RelationAction>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_6">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationAction"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>has</aapi:Text>
            <aapi:LemmatizedText>has</aapi:LemmatizedText>
            <aapi:VerbText>has</aapi:VerbText>
            <aapi:VerbTense>present</aapi:VerbTense>
        </rdf:Description>
    </aapi:RelationAction>
    <aapi:RelationObject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_6">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationObject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Name>a growth rate of 6,000 times</aapi:Name>
        </rdf:Description>
    </aapi:RelationObject>
</rdf:Description>
<rdf:Description rdf:ID="db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_7">
    <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationOccurrence"/>
    <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
    <aapi:RelationSentence> “Context is super-important,” he adds.</aapi:RelationSentence>
    <aapi:RelationSubject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_7">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationSubject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>Context</aapi:Text>
        </rdf:Description>
    </aapi:RelationSubject>
    <aapi:RelationAction>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_7">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationAction"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>is</aapi:Text>
            <aapi:LemmatizedText>be</aapi:LemmatizedText>
            <aapi:VerbText>be</aapi:VerbText>
            <aapi:VerbTense>present</aapi:VerbTense>
        </rdf:Description>
    </aapi:RelationAction>
    <aapi:RelationObject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_7">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationObject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Name>super-important</aapi:Name>
        </rdf:Description>
    </aapi:RelationObject>
</rdf:Description>
<rdf:Description rdf:ID="db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_8">
    <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationOccurrence"/>
    <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
    <aapi:RelationSentence> “Context is super-important,” he adds.</aapi:RelationSentence>
    <aapi:RelationSubject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_8">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationSubject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>he</aapi:Text>
        </rdf:Description>
    </aapi:RelationSubject>
    <aapi:RelationAction>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_8">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationAction"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>adds</aapi:Text>
            <aapi:LemmatizedText>add</aapi:LemmatizedText>
            <aapi:VerbText>add</aapi:VerbText>
            <aapi:VerbTense>present</aapi:VerbTense>
        </rdf:Description>
    </aapi:RelationAction>
    <aapi:RelationObject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_8">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationObject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Name>Context is super-important</aapi:Name>
        </rdf:Description>
    </aapi:RelationObject>
</rdf:Description>
<rdf:Description rdf:ID="db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_9">
    <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationOccurrence"/>
    <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
    <aapi:RelationSentence> “'I'm dying' is a lot different than 'I'm dying to buy the new iPhone.'”</aapi:RelationSentence>
    <aapi:RelationSubject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_9">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationSubject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>'I</aapi:Text>
        </rdf:Description>
    </aapi:RelationSubject>
    <aapi:RelationAction>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_9">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationAction"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Text>is</aapi:Text>
            <aapi:LemmatizedText>be</aapi:LemmatizedText>
            <aapi:VerbText>be</aapi:VerbText>
            <aapi:VerbTense>present</aapi:VerbTense>
        </rdf:Description>
    </aapi:RelationAction>
    <aapi:RelationObject>
        <rdf:Description rdf:about="#db844b19ba6b2a6bc2f4e1ea706f63335a63955cf-r_9">
            <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#RelationObject"/>
            <aapi:Doc>db844b19ba6b2a6bc2f4e1ea706f63335a63955cf</aapi:Doc>
            <aapi:Name>a lot different</aapi:Name>
        </rdf:Description>
    </aapi:RelationObject>
</rdf:Description>

0 个答案:

没有答案