Compilation issue with EMF Compare code - java

Version of EMF Compare: 2.1.0 M6 (2013/03/19 17:50)
I am trying to use standalone compare as explained in this guide. I get the below compilation error
The method setMatchEngine(IMatchEngine) is undefined for the type EMFCompare.Builder
for the below code
// Configure EMF Compare
IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
IMatchEngine matchEngine = new DefaultMatchEngine(matcher, comparisonFactory);
EMFCompare comparator = EMFCompare.builder().setMatchEngine(matchEngine).build();
I see that setMatchEngine is replaced by some other API as shown in the below figure. I am not sure how to specify the new matchEngine using that API.

These APIs have changed for M6 (the API are now in their final 2.1.0 stage as far as removals are concerned). A good source of "how to use the APIs" are the unit tests of EMF Compare if you have the code in your workspace.
For your particular use case, the code would look as such:
IMatchEngine.Factory factory = new MatchEngineFactoryImpl(UseIdentifiers.NEVER);
IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
matchEngineRegistry .add(factory);
EMFCompare comparator = EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build();
Note that using the default registry (EMFCompare.builder().build();) would be enough in most cases... except when you really can't let EMF Compare use the IDs :p.
[edit: a small note: we have now updated the wiki with accurate information, thanks for the feedback ;)]

Related

How to use MLeap DenseTensor in Java

I am using MLeap to run a Pyspark logistic regression model in a java program. Once I run the pipeline I am able to get a DefaultLeapFrame object with one row Stream(Row(1.3,12,3.6,DenseTensor([D#538613b3,List(2)),1.0), ?).
But I am not sure how to actually inspect the DenseTensor object. When I use getTensor(3) on this row I get an object. I am not familiar with Scala but that seems to be how this is meant to be interacted with. In Java how can I get the values within this DenseVector?
Here is roughly what I am doing. I'm guessing using Object is not right for the type. . .
DefaultLeapFrame df = leapFrameSupport.select(frame2, Arrays.asList("feat1", "feat2", "feat3", "probability", "prediction"));
Tensor<Object> tensor = df.dataset().head().getTensor(3);
Thanks
So the MLeap documentation for the Java DSL is not so good but I was able to look over some unit tests (link) that pointed me to the right thing to use. In case anyone else is interested, this is what I did.
DefaultLeapFrame df = leapFrameSupport.select(frame, Arrays.asList("feat1", "feat2", "feat3", "probability", "prediction"));
TensorSupport tensorSupport = new TensorSupport();
List<Double> tensor_vals = tensorSupport.toArray(df.dataset().head().getTensor(3));

Play framework 2.4 form fill does not work

In Play Framework 2.4 Java, I need to fill a form using the following code, but it does not work. The output value of usereditform.field("email").value() is null. Anyone know why?
SignupClz signupobj = new SignupClz();
signupobj.email="abcd#efgh.com";
signupobj.name="abcd";
signupobj.password = "eoijf";
Form<SignupClz> usereditform = Form.form(SignupClz.class).fill(signupobj);
System.out.println(usereditform.field("email").value());
This code is correct. Please look at other points - maybe you did not recognize "abcd#efgh.com" output in the console.
For example I have the similar code and it works:
EditForm rawEditForm = new EditForm();
rawEditForm.title = boxModel.title;
rawEditForm.body = boxModel.body;
rawEditForm.id = id;
Form<EditForm> editForm = Form.form(EditForm.class).fill(rawEditForm);
Logger.info("Title: " + editForm.field("title").value());
I am learning PlayFramework and stumbled upon this question.
For PlayFramework 2.8 form field values cannot be directly accessed, be it reading or filling(writing) information. You have to explicity tell it when building the form, like this :
#Inject
FormFactory formFactory;
Form<SignupClz> usereditform = FormFactory.form(SignupClz.class) //
.withDirectFieldAccess(true)
.fill(signupobj);
System.out.println(usereditform.field("email").value());
Note that in this version forms are built using FormFactory, make sure you inject it or add it to your code otherwise.
Details in their official documentation https://www.playframework.com/documentation/2.8.x/JavaForms#Defining-a-form:~:text=Instead%20of%20enabling%20%E2%80%9Cdirect%20field%20access%E2%80%9D%20for%20all%20forms%2C%20you%20can%20enable%20it%20only%20for%20specific%20ones%3A

RUL-05717: The identifier "Header.Teachers.Courses" is not valid here

I am trying to add rules in my Oracle dictionary through programming in ADF and JDeveloper:
Rule rule = ruleset.getRuleTable().add();
rule.setName(aliasRule);
rule.setAlias(aliasRule);
rule.setPriority(property);
rule.setAdvancedMode(true);
rule.setDescription(description);
return rule;
then:
diccionaryRules.validate(exceptions, warnings);
I have three warnings with the same message:
RUL-05717: The identifier "Header.Teachers.Courses" is not valid here.
Where in my Oracle.rules file I have three viewobjects connected by links through private key ids:
HeaderVVO
TeachersVVO
CoursesVVO
And the route is correct: Header.Teachers.Courses.
I created an expression from the follwoing path:
Header.Teachers by:
Expression ePath = simpleTest.getExpressionTable().get(0);
ePath.setValue("Header.Teachers");
// Here comes some validation
List<SDKWarning> warnings = new ArrayList<SDKWarning>();
List<SDKException> exceptions = new ArrayList<SDKException>();
ePath.validate(exceptions, warnings);
it doesn't give warnings, but this:
ePath.setValue("Header.Teachers.Courses");
gives the above warning.
I don't know why I get these warnings.
You should presume that most of the people trying to answer this question (myself included) while having a good understanding on ADF, don't know much about Oracle Rules.
That being said, this looks like a problem on Rules side, rather than on ADF. As I see you are using view objects, you can probably test this integration logic from Business Components Tester and you can inject your Rules logic through application modules custom methods.
Bottom line, you are building a Rules client from java, this is not directly related to ADF. If you can make your client work from a java main(String[] args) method, it will work from ADF too.

Custom Feature Generation in OpenNLP Namefinder API

I am trying to use the Custom Feature generation of OpenNLP for Named Finder API.
http://opennlp.apache.org/documentation/1.5.3/manual/opennlp.html
I went through the documentation but I was not able to understand how to specify the different features.
It just says:
AdaptiveFeatureGenerator featureGenerator = new CachedFeatureGenerator(
new AdaptiveFeatureGenerator[]{
new WindowFeatureGenerator(new TokenFeatureGenerator(), 2, 2),
new WindowFeatureGenerator(new TokenClassFeatureGenerator(true), 2, 2),
new OutcomePriorFeatureGenerator(),
new PreviousMapFeatureGenerator(),
new BigramNameFeatureGenerator(),
new SentenceFeatureGenerator(true, false)
});
But how do you actually use each of these different feature generators to create my own custom features. Can somebody post a sample code defining these feature generators and how do we use it for custom feature generation. Thanks in anticipation.
I did not find any documentation either, but for most feature generators the code is quite self explanatory. Here are some links to the source repository:
TokenFeatureGenerator
TokenClassFeatureGenerator
OutcomePriorFeatureGenerator
PreviousMapFeatureGenerator
SentenceFeatureGenerator
BigramNameFeatureGenerator
WindowFeatureGenerator
CachedFeatureGenerator
Furthermore, the documentation you refer to states that the quoted feature generator is similar to the default feature generator. However, the source code shows that it is actually identical to the default feature generator.

What is the difference between GraphDatabaseService or NeoService in neo4j

I'm learning to use neo4j, but am a bit confused on its usage. When I'm adding nodes and relationships, I can do it like this:
GraphDatabaseService graphDb = new EmbeddedGraphDatabase("C:/temp/graphdb");
Transaction tx = graphDb.beginTx();
try {
org.neo4j.graphdb.Node node = graphDb.createNode();
...
I could also do it like this:
NeoService neoService = new EmbeddedNeo("C:/temp/graphdb");
Transaction tx = neoService.beginTx();
try {
org.neo4j.api.core.Node node = neoService.createNode();
...
What is the difference here really? Which one should I use? Why are they 2 different mechanisms? Is this just API evolution here? :) I want to use the MetaModel API and it needs a NeoService, so the choice there is clear I guess.
Sorry,
you should use the first one, since in the latest 1.0-RC1 the namespace was moved. This is just naming, the semantics are the same. The second example is outdated and should be removed form the official documentation. Where did you find that?
Cheers,
/peter neubauer
You're spot on with the API evolution comment. The old API is NeoService, so you shouldn't use that. Go with your first snippet. For more information on the API change see e.g. the release mail for the latest rc:
http://www.mail-archive.com/user#lists.neo4j.org/msg02378.html
If you use the latest snapshot (0.7-SNAPSHOT) of the meta-model component, you'll find that it uses the latest API. For our 1.0 release (should be out Real Soon Now :), we're going to make non-SNAPSHOT releases of all components that will use the new API.
-EE
And regarding the meta model, please use the meta-model component (now with the maven artifactId: neo4j-meta-model).
I also notice that the component overview http://components.neo4j.org/neo4j-meta-model/ has some invalid example code and descriptions. I'll try to fix that.

Categories