-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #444 from silk-framework/feature/AutoSuggestionOnV…
…aluePathFields-CMEM-3052 Feature/auto suggestion on value path fields cmem 3052
- Loading branch information
Showing
78 changed files
with
2,856 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
silk-core/src/main/scala/org/silkframework/dataset/DataSourceCharacteristics.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.silkframework.dataset | ||
|
||
import org.silkframework.dataset.DataSourceCharacteristics.SupportedPathExpressions | ||
|
||
/** Characteristics of a data source. | ||
* | ||
* @param supportedPathExpressions The characteristics of the supported path expressions. | ||
*/ | ||
case class DataSourceCharacteristics(supportedPathExpressions: SupportedPathExpressions = SupportedPathExpressions()) | ||
|
||
object DataSourceCharacteristics { | ||
|
||
/** Sources that only support plain attributes (i.e., forward paths of length 1 without any filters) */ | ||
def attributesOnly: DataSourceCharacteristics = DataSourceCharacteristics() | ||
|
||
/** The kind of path expressions supported by a data source. | ||
* | ||
* @param multiHopPaths If enabled it is possible to define multi-hop paths (e.g. in RDF, JSON, XML). Else only single-hop | ||
* path are supported. | ||
* @param backwardPaths If the data source supports backward paths, i.e. reversing the direction of a property (e.g. in | ||
* RDF, JSON (parent), XML (parent)). | ||
* @param languageFilter If the data source supports language filters, i.e. is able to filter by different language versions | ||
* of property values (only supported in RDF). | ||
* @param propertyFilter If the data source supports (single-hop forward) property filters. | ||
* @param specialPaths The data source specific paths that are supported by a data source, e.g. row ID in CSV. | ||
*/ | ||
case class SupportedPathExpressions(multiHopPaths: Boolean = false, | ||
backwardPaths: Boolean = false, | ||
languageFilter: Boolean = false, | ||
propertyFilter: Boolean = false, | ||
specialPaths: Seq[SpecialPathInfo] = Seq.empty) | ||
|
||
/** | ||
* Information about data source specific special paths that have a special semantic. | ||
* | ||
* @param value The path value. | ||
* @param description Description of the semantics of the special path. | ||
*/ | ||
case class SpecialPathInfo(value: String, description: Option[String]) | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
silk-core/src/main/scala/org/silkframework/execution/local/LocalExecution.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
silk-core/src/test/scala/org/silkframework/entity/paths/PathParserTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.silkframework.entity.paths | ||
|
||
import org.scalatest.{FlatSpec, MustMatchers} | ||
import org.silkframework.config.Prefixes | ||
import org.silkframework.util.Uri | ||
|
||
class PathParserTest extends FlatSpec with MustMatchers { | ||
behavior of "path parser" | ||
|
||
val parser = new PathParser(Prefixes.default) | ||
private val SPACE = " " | ||
|
||
it should "parse the full path and not return any errors for valid paths" in { | ||
testValidPath("/a/b[d = 5]\\c") | ||
testValidPath("""\<urn:some:test>[<urn:prop:check> != "check value"]/abc""") | ||
testValidPath("""abc[@lang ='en']""").operators.drop(1).head mustBe LanguageFilter("=", "en") | ||
testValidPath("""abc[ @lang = 'en']""").operators.drop(1).head mustBe LanguageFilter("=", "en") | ||
} | ||
|
||
it should "parse invalid paths and return the parsed part and the position where it failed" in { | ||
testInvalidPath(inputString = "/a/b/c/not valid/d/e", expectedParsedString = "/a/b/c/not", expectedErrorOffset = 10, expectedInputOnError = SPACE, expectedNextParseOffset = "/a/b/c/not".length) | ||
testInvalidPath(inputString = s"$SPACE/alreadyInvalid/a", expectedParsedString = "", expectedErrorOffset = 0, expectedInputOnError = SPACE, expectedNextParseOffset = 0) | ||
testInvalidPath(inputString = """\<urn:test:1>/a[b :+ 1]/c""", expectedParsedString = "\\<urn:test:1>/a", expectedErrorOffset = 17, expectedInputOnError = "[b ", expectedNextParseOffset = "\\<urn:test:1>/a".length) | ||
testInvalidPath(inputString = """/a\b/c/""", expectedParsedString = """/a\b/c""",expectedErrorOffset = 6, expectedInputOnError = "/", expectedNextParseOffset = 6) | ||
testInvalidPath(inputString = """invalidNs:broken""", expectedParsedString = "",expectedErrorOffset = 0, expectedInputOnError = "", expectedNextParseOffset = 0) | ||
testInvalidPath(inputString = """<'""", expectedParsedString = "",expectedErrorOffset = 0, expectedInputOnError = "<", expectedNextParseOffset = 0) | ||
} | ||
|
||
it should "partially parse filter expressions correctly" in { | ||
parser.parseUntilError("""a/b[@lang = "en"]""").error must not be defined | ||
val result = parser.parseUntilError("""a/b[@lang = "en"]/error now""") | ||
val error = result.error | ||
error mustBe defined | ||
error.get.offset mustBe """a/b[@lang = "en"]/error""".length | ||
} | ||
|
||
private def testValidPath(inputString: String): UntypedPath = { | ||
val result = parser.parseUntilError(inputString) | ||
result mustBe PartialParseResult(UntypedPath.parse(inputString), None) | ||
result.partialPath | ||
} | ||
|
||
private def testInvalidPath(inputString: String, | ||
expectedParsedString: String, | ||
expectedErrorOffset: Int, | ||
expectedInputOnError: String, | ||
expectedNextParseOffset: Int): Unit = { | ||
val result = parser.parseUntilError(inputString) | ||
result.copy(error = result.error.map(e => e.copy(message = ""))) mustBe PartialParseResult( | ||
UntypedPath.parse(expectedParsedString), | ||
Some(PartialParseError(expectedErrorOffset, "", expectedInputOnError, expectedNextParseOffset)) | ||
) | ||
} | ||
} |
Oops, something went wrong.