I am trying the example of uima ruta:
here.
I want to create ruta script and apply it to my text (from plain java without any workbench).
1.how do i get the type system descriptor from plain java (without workbench)?
2. when do i get it with workbench? (if i "run" the ruta script, no description were made.)
The main question is whether the script declares new types.
If no new types are declared, the linked examples in the documentation should be sufficient.
If new types are declared in the script, then a type system description needs to be created and included in the creation process of the CAS before the script can be applied on the CAS.
The type system description of a script containing the type descriptions of the types declared within the script can be created the following ways:
The Ruta Workbench creates the type system description automatically for each script within a simple Ruta Project when the script is saved. If no description is created, the script is most likely not parseable and contains syntax errors.
In maven-built projects, the ruta-maven-plugin can be utilized to create the type system descriptions of Ruta scripts.
In plain Java, the RutaDescriptorFactory can be utilized to create the type system description programmatically. Here's a code example.
There are several ways to create and execute a ruta-based analysis engine in plain java code. Here's an example without using additional files:
String rutaScript = "DECLARE MyType; CW{-> MyType};";
RutaDescriptorFactory descriptorFactory = new RutaDescriptorFactory();
RutaBuildOptions options = new RutaBuildOptions();
options.setResolveImports(true);
options.setImportByName(true);
RutaDescriptorInformation descriptorInformation = descriptorFactory
.parseDescriptorInformation(rutaScript, options);
// replace null values for build environment if necessary (e.g., location in classpath)
Pair<AnalysisEngineDescription, TypeSystemDescription> descriptions = descriptorFactory
.createDescriptions(null, null, descriptorInformation, options, null, null, null);
AnalysisEngineDescription rutaAnalysisEngineDescription = descriptions.getKey();
rutaAnalysisEngineDescription.getAnalysisEngineMetaData().getConfigurationParameterSettings().setParameterValue(RutaEngine.PARAM_RULES, rutaScript);
TypeSystemDescription rutaTypeSystemDescription = descriptions.getValue();
// directly set type system description since no file will be created
rutaAnalysisEngineDescription.getAnalysisEngineMetaData().setTypeSystem(rutaTypeSystemDescription);
ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(rutaAnalysisEngineDescription);
List<TypeSystemDescription> typeSystemDescriptions = new ArrayList<>();
TypeSystemDescription scannedTypeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescription();
typeSystemDescriptions.add(scannedTypeSystemDescription);
typeSystemDescriptions.add(rutaTypeSystemDescription);
TypeSystemDescription mergeTypeSystemDescription = CasCreationUtils.mergeTypeSystems(typeSystemDescriptions, resourceManager);
JCas jCas = JCasFactory.createJCas(mergeTypeSystemDescription);
CAS cas = jCas.getCas();
jCas.setDocumentText("This is my document.");
ae.process(jCas);
Collection<AnnotationFS> select = CasUtil.select(cas, cas.getTypeSystem().getType("Anonymous.MyType"));
for (AnnotationFS each : select) {
System.out.println(each.getCoveredText());
}
DISCLAIMER: I am a developer of UIMA Ruta
Related
So, I am making a custom plugin for my server, and one of my features requires me to set an integer in a gui that shows how many 'CommonPackages' a user has. The issue that I am having is that when I am getting the String from my config (My config uses a custom file creation/management class that was given to me by a friend) it is saying that it is null in the gui, I do not get any errors in the console, please may someone help me? The item in the gui and the code for setting the item in the gui.
Item in the gui
gui creation code:
public static Inventory WhiteBackpack(Player player) {
UUID uuid = player.getUniqueId();
Inventory inv = Bukkit.createInventory(null, 27, (inventoryname));
ItemStack common = new ItemStack(Material.INK_SACK);
common.setDurability((byte) 8);
ItemMeta commonMeta = common.getItemMeta();
commonMeta.setDisplayName(Utils.chat("&fCommon Packages &8ยป &f&l" + Main.pl.getFileControl().getConfig().getString("players." + uuid + ".Packages.Common"))); //How I access my custom configs.
common.setItemMeta(commonMeta);
inv.setItem(10, common);
return inv;
}
Without the code of your method to get the config I can only say that the string in the actual file is not present.
As the Bukkit documentation states:
If the String does not exist and no default value was specified, this will return null.
So either the key just does not exist in the file or you pointed to the wrong file. The configuration should be well formated, too. (no tabs, only spaces)
I'm working on azure mobile services scripts. While being in insert script code of one table I want to insert a record in another table. I know it is possible using table.insert() function, but I'm not finding out a way to initialize a table object inside the script. The script doesn't recognize the Table name as a type that could be initialized. May be I'm missing some basic point. Following code might help you understand:
function insert(item, user, request) {
Misc misc = new Misc(); // 'Misc' is the table name and it is not recognized as a type.
misc.name = "John";
var tblMisc = tables.getTable('Misc');
tblMisc.insert(misc);
...}
Azure Mobile Services scripting language is Node.js which is dynamically typed, so Misc misc = new Misc(); won't work.
You could change your first line to:
var misc = {};
Or just replace everything with:
tables.getTable('Misc').insert({ name: "John" });
I'm trying to query QBO for, among other entities, Accounts, and am running into a couple of issues. I'm using the .Net Dev Kit v 2.1.10.0 (I used NuGet to update to the latest version) and when I use the following technique:
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
IEnumerable<Intuit.Ipp.Data.Qbo.Account> qboAccounts = cquery.ExecuteQuery<Intuit.Ipp.Data.Qbo.Account>(context);
(i.e. just create a new AccountQuery of the appropriate type and call ExecuteQuery) I get an error. It seems that the request XML is not created properly, I just see one line in the XML file. I then looked at the online docs and tried to emulate the code there:
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
cquery.CreateTime = DateTime.Now.Date.AddDays(-20);
cquery.SpecifyOperatorOption(Intuit.Ipp.Data.Qbo.FilterProperty.CreateTime,
Intuit.Ipp.Data.Qbo.FilterOperatorType.AFTER);
cquery.CreateTime = DateTime.Now.Date;
cquery.SpecifyOperatorOption(Intuit.Ipp.Data.Qbo.FilterProperty.CreateTime,
Intuit.Ipp.Data.Qbo.FilterOperatorType.BEFORE);
// Specify a Request validator
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
IEnumerable<Intuit.Ipp.Data.Qbo.Account> qboAccounts = cquery.ExecuteQuery<Intuit.Ipp.Data.Qbo.Account>(context);
unfortunately, VS 2010 insists that AccountQuery doesn't contain a definition for SpecifyOperatorOption and there is no extension method by that name. So I'm stuck.
Any ideas how to resolve this would be appreciated.
i am creating java source files using eclipse JDT & AST. There are cases that generated source files are implementing or extending something.
is it possible to add method stubs automatically before actually creating them? like invoking this "Add unimplemented methods" quick fix via JDT.
i know i can add them myself via those API's, but i want to tweak.
i found solution after a couple of hours; code is roughly like this. there are also many good code manipulation classes in this package "org.eclipse.jdt.internal.corext.codemanipulation.*"
ICompilationUnit createCompilationUnit = getItSomeHow();
RefactoringASTParser parser1 = new RefactoringASTParser(AST.JLS3);
CompilationUnit unit = parser1.parse(createCompilationUnit, true);
AbstractTypeDeclaration declaration = (AbstractTypeDeclaration) ASTNodes.getParent(
NodeFinder.perform(unit, createCompilationUnit.getTypes()[0].getNameRange()),
AbstractTypeDeclaration.class);
ITypeBinding binding = declaration.resolveBinding();
IMethodBinding[] overridableMethods = StubUtility2.getOverridableMethods(unit.getAST(), binding, false);
AddUnimplementedMethodsOperation op = new AddUnimplementedMethodsOperation(unit, binding,
null/* overridableMethods */, -1, true, true, true);
I have a custom application with a simple app.config specifying SQL Server name and Database, I want to prompt the user on application install for application configuration items and then update the app.config file.
I admit I'm totally new to setup projects and am looking for some guidance.
Thank You
Mark Koops
I had problems with the code Gulzar linked to on a 64 bit machine. I found the link below to be a simple solution to getting values from the config ui into the app.config.
http://raquila.com/software/configure-app-config-application-settings-during-msi-install/
check this out - Installer with a custom action for changing settings
App.Config CAN be changed...however it exists in a location akin to HKEY___LOCAL_MACHINE i.e. the average user has read-only access.
So you will need to change it as an administrator - best time would be during installation, where you're (supposed to be) installing with enhanced permissions.
So create an Installer class, use a Custom Action in the setup project to pass in the user's choices (e.g. "/svr=[SERVER] /db=[DB] /uilevel=[UILEVEL]") and, in the AfterInstall event, change the App.Config file using something like:
Public Shared Property AppConfigSetting(ByVal SettingName As String) As Object
Get
Return My.Settings.PropertyValues(SettingName)
End Get
Set(ByVal value As Object)
Dim AppConfigFilename As String = String.Concat(System.Reflection.Assembly.GetExecutingAssembly.Location, ".config")
If (My.Computer.FileSystem.FileExists(AppConfigFilename)) Then
Dim AppSettingXPath As String = String.Concat("/configuration/applicationSettings/", My.Application.Info.AssemblyName, ".My.MySettings/setting[#name='", SettingName, "']/value")
Dim AppConfigXML As New System.Xml.XmlDataDocument
With AppConfigXML
.Load(AppConfigFilename)
Dim DataNode As System.Xml.XmlNode = .SelectSingleNode(AppSettingXPath)
If (DataNode Is Nothing) Then
Throw New Xml.XmlException(String.Format("Application setting not found ({0})!", AppSettingXPath))
Else
DataNode.InnerText = value.ToString
End If
.Save(AppConfigFilename)
End With
Else
Throw New IO.FileNotFoundException("App.Config file not found!", AppConfigFilename)
End If
End Set
End Property
Create custom dialogs for use in your Visual Studio Setup projects:
http://www.codeproject.com/Articles/18834/Create-custom-dialogs-for-use-in-your-Visual-Studi