Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The code for the answer from the previous question was</p> <pre class="lang-java prettyprint-override"><code>public static int classSize( final Resource klass ) { return klass.getModel().listSubjectsWithProperty( RDFS.subClassOf, klass ).toList().size(); } public static double pathSize( final List&lt;Resource&gt; path ) { int prevSize = classSize( path.get( 0 )); double pathSum = prevSize; for ( int i = 1; i &lt; path.size(); i++ ) { int currSize = classSize( path.get( i )); double linkWeight = currSize &lt; prevSize ? 0.5 : 1.0; pathSum += linkWeight + currSize; prevSize = currSize; } return pathSum; } </code></pre> <p>It's not exactly clear to me what it is that you're trying to do, but it sounds like you're trying to adjust the <code>currSize</code> in <code>pathSize</code> for certain classes (i.e., the value of returned by <code>path.get( i )</code>, but that you're having trouble comparing whether or not the class is one of the classes for which this should happen. If I'm understanding correctly, you can do something like this:</p> <pre class="lang-java prettyprint-override"><code>private static Resource specialClass = ResourceFactory.createResource( "http://.../specialClass" ); public static double pathSize( final List&lt;Resource&gt; path ) { // ... for ( int i = 1; i &lt; path.size(); i++ ) { final Resource klass = path.get( i ); int currSize = classSize( klass ); if ( specialClass.equals( klass ) ) { // When klass is specialClass currSize = ...; // something different // do the additional modification } // ... } // ... } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload