Custom Feature Generation in OpenNLP Namefinder API - java

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.

Related

How to solve com.ibm.watson.developer_cloud.service.exception.NotFoundException in IBM Watson?

I am trying to incorporate IBM Watson translation library in my application.
Below is the sample code that i am trying
LanguageTranslator service = new LanguageTranslator();
service.setUsernameAndPassword("user","password");
TranslateOptions translateOptions = new TranslateOptions.Builder()
.addText("नमस्ते")
.source(Language.HINDI)
.target(Language.ENGLISH)
.build();
TranslationResult result = service.translate(translateOptions)
.execute();
System.out.println(result);
When i use source language as Language.HINDI and target as Language.ENGLISH, i am getting the following exception.
Exception in thread "main" com.ibm.watson.developer_cloud.service.exception.NotFoundException: Model not found.
at com.ibm.watson.developer_cloud.service.WatsonService.processServiceCall(WatsonService.java:415)
at com.ibm.watson.developer_cloud.service.WatsonService$1.execute(WatsonService.java:174)
at com.terrierdemo.LanguageTranslatorIBM.main(LanguageTranslatorIBM.java:23)
But for some language combinations(Language.ENGLISH|Language.SPANISH) I am getting expected result. Could anyone help me on this?
From your error description, it is clear that the translator model is not available for your source and target languages. You Check for the available source models using this List Models. I did not see any default model that can translate Hindi to English. You need to create a model for this. Create Model

How to Know Model Type using AWS Java SDK for Machine Learning

I am using AWS Java SDK to generate RealTime Predictions. To get the output of prediction i need to know what kind of machine learning model is being used is it binary , regression or multiclass. I have only the model id which i can use to locate model.Is there any API or some other way through which i can know the model type in my application.
I have searched through the documentation but haven't found anything that suits my requirement.
You can get the model type by calling the GetMLModel API.
AmazonMachineLearningClient client = ...;
GetMLModelRequest request = new GetMLModelRequest().withMLModelId("...");
client.getMLModel(request).getMLModelType();

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.

Compilation issue with EMF Compare code

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 ;)]

Required Java API to generate Database ER diagram

Is there any java API/java plugin which can generate Database ER diagram when java connection object is provided as input.
Ex: InputSream generateDatabaseERDiagram(java connection object)// where inputsream will point to generated ER diagram image
The API should work with oracle,mysql,postgresql?
I was going through schemacrawler(http://schemacrawler.sourceforge.net/) tool but didint got any API which could do this.
If no API like this is there then let me know how can write my own API? I want to generate ER diagram for all the schema in a database or any specific schema if the schema name is provided as input.
It will be helpful if you show some light on how to achieve this task.
If I understood you question correctly, you might take a look at: JGraph
This is an old question but in case anyone else stumbles across it as I did when trying to do the same thing I eventually figured out how to generate the ERD using Schemacrawler's java API.
//Get your java connection however
Connection conn = DriverManager.getConnection("DATABASE URL");
SchemaCrawlerOptions options = new SchemaCrawlerOptions();
// Set what details are required in the schema - this affects the
// time taken to crawl the schema
options.setSchemaInfoLevel(SchemaInfoLevelBuilder.standard());
// you can exclude/include objects using the options object e.g.
//options.setTableInclusionRule(new RegularExpressionExclusionRule(".*qrtz.*||.*databasechangelog.*"));
GraphExecutable ge = new GraphExecutable();
ge.setSchemaCrawlerOptions(options);
String outputFormatValue = GraphOutputFormat.png.getFormat();
OutputOptions outputOptions = new OutputOptions(outputFormatValue, new File("database.png").toPath());
ge.setOutputOptions(outputOptions);
ge.execute(conn);
This still requires graphviz to be installed and on the path to work.

Categories