-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate EOSC services mining with IIS primary workflow #1398
Closed
marekhorst
wants to merge
9
commits into
master
from
marekhorst_1049_perform_test_mining_for_EOSC_services
Closed
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2ba28b7
Closes #1049: Perform test mining for EOSC services
marekhorst f63873a
Closes #1393: Remove obsolete DeduplicationMappingConverter
marekhorst 324b6a8
Closes #1394: Integrate EOSC services mining with IIS primary workflow
marekhorst c9a93e4
Closes #1394: Integrate EOSC services mining with IIS primary workflow
marekhorst eb577b0
Closes #1394: Integrate EOSC services mining with IIS primary workflow
marekhorst 1325e29
Closes #1394: Integrate EOSC services mining with IIS primary workflow
marekhorst c785566
Closes #1394: Integrate EOSC services mining with IIS primary workflow
marekhorst 476a378
Closes #1394: Integrate EOSC services mining with IIS primary workflow
marekhorst 48a9c5b
Closes #1394: Integrate EOSC services mining with IIS primary workflow
marekhorst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
iis-schemas/src/main/avro/eu/dnetlib/iis/importer/Service.avdl
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,18 @@ | ||
@namespace("eu.dnetlib.iis.importer.schemas") | ||
|
||
protocol IIS { | ||
|
||
record Service { | ||
|
||
// InformationSpace service identifier | ||
string id; | ||
|
||
// service name | ||
union {null , string} name; | ||
|
||
// service url | ||
string url; | ||
} | ||
|
||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...mas/src/main/avro/eu/dnetlib/iis/referenceextraction/datasource/DocumentToDatasource.avdl
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,15 @@ | ||
@namespace("eu.dnetlib.iis.referenceextraction.datasource.schemas") | ||
protocol IIS{ | ||
|
||
record DocumentToDatasource { | ||
// document identifier, foreign key: DocumentWithBasicMetadata.id ("document basic metadata" data store) | ||
string documentId; | ||
// identifier of the referenced datasource, | ||
// foreign key: Datasource.id | ||
string datasourceId; | ||
// Find more details on `confidenceLevel` constraints in eu/dnetlib/iis/README.markdown file. | ||
float confidenceLevel; | ||
// text snippet surrounding the matched reference, required mostly for internal debugging and analytics | ||
union { null , string } textsnippet = null; | ||
} | ||
} |
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
84 changes: 84 additions & 0 deletions
84
...ib/iis/wf/export/actionmanager/module/DocumentToDatasourceActionBuilderModuleFactory.java
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,84 @@ | ||
package eu.dnetlib.iis.wf.export.actionmanager.module; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
|
||
import eu.dnetlib.dhp.schema.action.AtomicAction; | ||
import eu.dnetlib.dhp.schema.oaf.Relation; | ||
import eu.dnetlib.iis.referenceextraction.datasource.schemas.DocumentToDatasource; | ||
import eu.dnetlib.iis.wf.export.actionmanager.OafConstants; | ||
|
||
/** | ||
* {@link DocumentToDatasource} based action builder module. | ||
* | ||
* @author mhorst | ||
* | ||
*/ | ||
public class DocumentToDatasourceActionBuilderModuleFactory extends AbstractActionBuilderFactory<DocumentToDatasource, Relation> { | ||
|
||
|
||
// ------------------------ CONSTRUCTORS -------------------------- | ||
|
||
public DocumentToDatasourceActionBuilderModuleFactory() { | ||
super(AlgorithmName.document_referencedDatasources); | ||
} | ||
|
||
// ------------------------ LOGIC --------------------------------- | ||
|
||
@Override | ||
public ActionBuilderModule<DocumentToDatasource, Relation> instantiate(Configuration config) { | ||
return new DocumentToDatasourceActionBuilderModule(provideTrustLevelThreshold(config)); | ||
} | ||
|
||
// ------------------------ INNER CLASS -------------------------- | ||
|
||
class DocumentToDatasourceActionBuilderModule extends AbstractBuilderModule<DocumentToDatasource, Relation> { | ||
|
||
|
||
// ------------------------ CONSTRUCTORS -------------------------- | ||
|
||
/** | ||
* @param trustLevelThreshold trust level threshold or null when all records should be exported | ||
*/ | ||
public DocumentToDatasourceActionBuilderModule(Float trustLevelThreshold) { | ||
super(trustLevelThreshold, buildInferenceProvenance()); | ||
} | ||
|
||
// ------------------------ LOGIC -------------------------- | ||
|
||
@Override | ||
public List<AtomicAction<Relation>> build(DocumentToDatasource object) throws TrustLevelThresholdExceededException { | ||
return Arrays.asList( | ||
createAction(object.getDocumentId().toString(), object.getDatasourceId().toString(), | ||
object.getConfidenceLevel(), OafConstants.REL_CLASS_REFERENCES), | ||
createAction(object.getDatasourceId().toString(), object.getDocumentId().toString(), | ||
object.getConfidenceLevel(), OafConstants.REL_CLASS_IS_REFERENCED_BY)); | ||
} | ||
|
||
// ------------------------ PRIVATE -------------------------- | ||
|
||
/** | ||
* Creates similarity related actions. | ||
*/ | ||
private AtomicAction<Relation> createAction(String source, String target, float confidenceLevel, | ||
String relClass) throws TrustLevelThresholdExceededException { | ||
AtomicAction<Relation> action = new AtomicAction<>(); | ||
action.setClazz(Relation.class); | ||
|
||
Relation relation = new Relation(); | ||
relation.setSource(source); | ||
relation.setTarget(target); | ||
relation.setRelType(OafConstants.REL_TYPE_RESULT_DATASOURCE); | ||
relation.setSubRelType(OafConstants.SUBREL_TYPE_RELATIONSHIP); | ||
relation.setRelClass(relClass); | ||
relation.setDataInfo(buildInference(confidenceLevel)); | ||
relation.setLastupdatetimestamp(System.currentTimeMillis()); | ||
|
||
action.setPayload(relation); | ||
|
||
return action; | ||
} | ||
} | ||
} |
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
85 changes: 85 additions & 0 deletions
85
...is/wf/export/actionmanager/module/DocumentToDatasourceActionBuilderModuleFactoryTest.java
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,85 @@ | ||
package eu.dnetlib.iis.wf.export.actionmanager.module; | ||
|
||
import eu.dnetlib.dhp.schema.action.AtomicAction; | ||
import eu.dnetlib.dhp.schema.oaf.Relation; | ||
import eu.dnetlib.iis.referenceextraction.datasource.schemas.DocumentToDatasource; | ||
import eu.dnetlib.iis.wf.export.actionmanager.OafConstants; | ||
import eu.dnetlib.iis.wf.export.actionmanager.module.VerificationUtils.Expectations; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static eu.dnetlib.iis.wf.export.actionmanager.module.VerificationUtils.assertOafRel; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* @author mhorst | ||
* | ||
*/ | ||
public class DocumentToDatasourceActionBuilderModuleFactoryTest extends AbstractActionBuilderModuleFactoryTest<DocumentToDatasource, Relation> { | ||
|
||
|
||
// ----------------------- CONSTRUCTORS ------------------- | ||
|
||
public DocumentToDatasourceActionBuilderModuleFactoryTest() throws Exception { | ||
super(DocumentToDatasourceActionBuilderModuleFactory.class, AlgorithmName.document_referencedDatasources); | ||
} | ||
|
||
// ----------------------- TESTS -------------------------- | ||
|
||
|
||
@Test | ||
public void testBuildBelowThreshold() { | ||
// given | ||
DocumentToDatasource documentToDataset = buildDocumentToDataset("documentId", "datasourceId", 0.4f); | ||
ActionBuilderModule<DocumentToDatasource, Relation> module = factory.instantiate(config); | ||
|
||
// execute | ||
assertThrows(TrustLevelThresholdExceededException.class, () -> module.build(documentToDataset)); | ||
} | ||
|
||
@Test | ||
public void testBuild() throws Exception { | ||
// given | ||
String docId = "documentId"; | ||
String datasourceId = "datasourceId"; | ||
float matchStrength = 0.9f; | ||
ActionBuilderModule<DocumentToDatasource, Relation> module = factory.instantiate(config); | ||
|
||
// execute | ||
List<AtomicAction<Relation>> actions = module.build(buildDocumentToDataset(docId, datasourceId, matchStrength)); | ||
|
||
// assert | ||
assertNotNull(actions); | ||
assertEquals(2, actions.size()); | ||
|
||
AtomicAction<Relation> action = actions.get(0); | ||
assertNotNull(action); | ||
assertEquals(Relation.class, action.getClazz()); | ||
Expectations expectations = new Expectations(docId, datasourceId, matchStrength, | ||
OafConstants.REL_TYPE_RESULT_DATASOURCE, OafConstants.SUBREL_TYPE_RELATIONSHIP, | ||
OafConstants.REL_CLASS_REFERENCES); | ||
assertOafRel(action.getPayload(), expectations); | ||
|
||
// checking backward relation | ||
action = actions.get(1); | ||
assertNotNull(action); | ||
assertEquals(Relation.class, action.getClazz()); | ||
expectations.setSource(datasourceId); | ||
expectations.setTarget(docId); | ||
expectations.setRelationClass(OafConstants.REL_CLASS_IS_REFERENCED_BY); | ||
assertOafRel(action.getPayload(), expectations); | ||
} | ||
|
||
// ----------------------- PRIVATE -------------------------- | ||
|
||
private static DocumentToDatasource buildDocumentToDataset(String docId, String datasourceId, | ||
float confidenceLevel) { | ||
DocumentToDatasource.Builder builder = DocumentToDatasource.newBuilder(); | ||
builder.setDocumentId(docId); | ||
builder.setDatasourceId(datasourceId); | ||
builder.setConfidenceLevel(confidenceLevel); | ||
return builder.build(); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...wf/export/actionmanager/sequencefile/sampledataproducer/input/document_to_datasource.json
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 @@ | ||
{"documentId":"id-10","datasourceId":"dsid-1","confidenceLevel":0.8164966, "textsnippet": null} |
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
15 changes: 15 additions & 0 deletions
15
.../actionmanager/sequencefile/sampledataproducer/output/document_to_datasource_1.properties
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,15 @@ | ||
clazz.canonicalName=eu.dnetlib.dhp.schema.oaf.Relation | ||
|
||
payload.relType=resultDatasource | ||
payload.subRelType=relationship | ||
payload.relClass=References | ||
payload.source=id-10 | ||
payload.target=dsid-1 | ||
|
||
payload.dataInfo.inferred=true | ||
payload.dataInfo.trust=0.7348 | ||
payload.dataInfo.inferenceprovenance=iis::document_referencedDatasources | ||
payload.dataInfo.provenanceaction.classid=iis | ||
payload.dataInfo.provenanceaction.classname=iis | ||
payload.dataInfo.provenanceaction.schemeid=dnet:provenanceActions | ||
payload.dataInfo.provenanceaction.schemename=dnet:provenanceActions |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm probably missing something, but is this code related to similarity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, this is probably some copy/paste leftover. Fixed.