假设我有以下Turtle声明:
@prefix : <http://example.org#> .
:ls :list (:a :b :c)
Run Code Online (Sandbox Code Playgroud)
有没有办法获得集合中元素的位置?
例如,使用此查询:
PREFIX : <http://example.org#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?elem WHERE {
?x :list ?ls .
?ls rdf:rest*/rdf:first ?elem .
}
Run Code Online (Sandbox Code Playgroud)
我明白了:
--------
| elem |
========
| :a |
| :b |
| :c |
--------
Run Code Online (Sandbox Code Playgroud)
但我想要一个查询来获取:
--------------
| elem | pos |
==============
| :a | 0 |
| :b | 1 |
| :c | 2 |
--------------
Run Code Online (Sandbox Code Playgroud)
可能吗?
我有一个Play项目,它使用最近移植到Scala 2.11.1的库.
我还更新了Play to Scala 2.11.1.
当我尝试运行该项目时,我得到:
[error] Modules were resolved with conflicting cross-version suffixes in {file:/...}:
[error] org.scalaz:scalaz-core _2.11, _2.10
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) Conflicting cross-version suffixes in: org.scalaz:scalaz-core
Run Code Online (Sandbox Code Playgroud)
我试图使用sbt-dependency-graph插件检测哪个是使用scalaz-core-2.10的库.但是,在依赖图树中,只有一个scalaz-core的外观:
info] | +-org.scalaz:scalaz-core_2.11:7.0.6
Run Code Online (Sandbox Code Playgroud)
所以我不确定使用scalaz-core_2.10的库是哪个...如何检测它?
我在这里看到,一旦我发现它,我可以排除它,但我的问题是如何检测哪个是我必须排除的依赖.
scala dependency-management sbt playframework playframework-2.0
我试图在Play 2.0框架中运行示例,但是当我去运行"play"或"sbt"时.
当我进入目录"/ samples/scala/helloworld"时,我执行"sbt"并获得:
[info] Loading project definition from C:\src\Play20\samples\scala\helloworld\project
[warn] module not found: play#sbt-plugin;2.0
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/play/sbt-plugin/scala_2.9.2/sbt_0.12/2.0/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/play/sbt-plugin/scala_2.9.2/sbt_0.12/2.0/ivys/ivy.xml
[warn] ==== local: tried
[warn] C:\Users\labra\.ivy2\local\play\sbt-plugin\scala_2.9.2\sbt_0.12\2.0\ivys\ivy.xml
[warn] ==== Typesafe repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/play/sbt-plugin_2.9.2_0.12/2.0/sbt-plugin-2.0.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/play/sbt-plugin_2.9.2_0.12/2.0/sbt-plugin-2.0.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: play#sbt-plugin;2.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes. …
Run Code Online (Sandbox Code Playgroud) 如何在Eclipse Neon中禁用欢迎屏幕?
尽管Eclipse Juno存在类似的问题,但建议的方法似乎在Eclipse Neon中不起作用.
我发现的一个问题是我有复选框:已always show Welcome at start up
选中.如果我取消选中它并重新启动Eclipse Neon,它将再次被检查.
我去的时候会发生同样的行为Help->Welcome
,似乎复选框无效.
我禁用欢迎屏幕的主要原因是,当显示欢迎屏幕时,我是否可以解决Ctrol-Arrow
s不能正常工作的问题.所以如果有另一个解决方案,我也会感激.
我也试图删除文件中的行-showsplash
,Eclipse.ini
但它似乎也没有工作.
我注意到只在使用Windows 7时才会出现问题.我尝试使用Windows 10,它似乎工作.所以,问题可能与Windows 7有关.
我想知道是否有一些函数可以在SPARQL中操作RDF集合.
一个激励性问题如下.
假设你有:
@prefix : <http://example.org#> .
:x1 :value 3 .
:x2 :value 5 .
:x3 :value 6 .
:x4 :value 8 .
:list :values (:x1 :x2 :x3 :x4) .
Run Code Online (Sandbox Code Playgroud)
并且您想要计算以下公式:((Xn - Xn-1)+ ...(X2 - X1))/(N - 1)
有一些通用的方法来计算它吗?
到目前为止,我只能为一组固定的值计算它.例如,对于4个值,我可以使用以下查询:
prefix : <http://example.org#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?r {
?list :values ?ls .
?ls rdf:first ?x1 .
?ls rdf:rest/rdf:first ?x2 .
?ls rdf:rest/rdf:rest/rdf:first ?x3 .
?ls rdf:rest/rdf:rest/rdf:rest/rdf:first ?x4 .
?x1 :value ?v1 .
?x2 :value ?v2 .
?x3 :value ?v3 …
Run Code Online (Sandbox Code Playgroud) 我想使用SPARQL创建观察排名.假设我有:
@prefix : <http://example.org#> .
:A :value 60 .
:B :value 23 .
:C :value 89 .
:D :value 34 .
Run Code Online (Sandbox Code Playgroud)
排名应该是:C = 1(最高),:A = 2,:D = 3,:B = 4.到目前为止,我能够使用以下查询解决它:
prefix : <http://example.org#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?x ?v ?ranking {
?x :value ?v .
{ SELECT (GROUP_CONCAT(?x;separator="") as ?ordered) {
{ SELECT ?x {
?x :value ?v .
} ORDER BY DESC(?v)
}
}
}
BIND (str(?x) as ?xName)
BIND (strbefore(?ordered,?xName) as ?before)
BIND ((strlen(?before) / strlen(?xName)) + 1 …
Run Code Online (Sandbox Code Playgroud) 想象一下,你有一个简单的社交网络,人们必须只有一个rdfs:label
有价值的财产,"Person"
并且任何数量的foaf:knows
人也必须是具有相同结构的人.一些示例数据可能是:
:peter foaf:knows :john;
foaf:knows :anna;
rdfs:label "Person" .
:john foaf:knows :anna;
rdfs:label "Person" .
:anna rdfs:label "Person" .
Run Code Online (Sandbox Code Playgroud)
在逻辑术语中,定义可能类似于:
∀x(Person(x)≡rdfs:label(x,"Person")∧∀y(rdfs:label(x,y)→y ="Person")∧∀y(foaf:knows(x,y)→人(Y)))
是否可以在SPARQL中表达这些递归定义?
我能够表达部分查询而没有递归引用foaf:knows
as:
PREFIX ex: <http://xmlns.com/foaf/0.1/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
select ?person {
# Ensure there is only one rdfs:label
{ SELECT ?person {
?person rdfs:label ?o .
} GROUP BY ?person HAVING (COUNT(*)=1)}
# Ensure the rdfs:label value is "Person"
{ SELECT ?person {
?person rdfs:label ?o .
FILTER …
Run Code Online (Sandbox Code Playgroud) 我想用一个抽象类型Value
的限制属于类型类Show
的猫科动物.
我的第一次尝试将是这样的:
package examples
import cats._
import cats.data._
import cats.implicits._
class UsingShow1 {
type Value <: Show[Value] // Not sure if this declaration is right
def showValues(vs: List[Value]): String =
vs.map(implicitly[Show[Value]].show(_)).mkString // Error line
}
Run Code Online (Sandbox Code Playgroud)
但是编译器没有找到隐含参数Show[Value]
.
我知道我可以将前面的例子定义为:
class UsingShow2[Value: Show] {
def showValues(vs: List[Value]): String =
vs.map(implicitly[Show[Value]].show(_)).mkString
}
Run Code Online (Sandbox Code Playgroud)
但是,我想知道是否可以使用抽象类型而不是类型参数.
sparql ×4
rdf ×3
scala ×3
sbt ×2
constraints ×1
eclipse ×1
eclipse-neon ×1
recursion ×1
scala-cats ×1