Carrot2-bisectingKmeans setting the attribute of resouceLookup causes the error of no resouces named stopwords.ar - k-means

Carrot2-I tried to cluster docs through the bisectingKmeans algorithm.
I set the attribute of resouceLookup and tested the language of English/Chinese. It both resulted in the error "no resouces named stopwords.ar in resouce lookup locations...".
The cod I wrote:
//set the resoucelookup
File resDir = new File("resouces");
ResouceLookup res = new ResouceLookup(new DirLocator(resDir));
LexicalDataLoaderDescriptor.attributeBuilder(preprocessAttr).resourceLookup(res);
//set the language
MultilingualClusteringDescriptor.attributeBuilder(processingAttr)
.defaultLanguage(LanguageCode.CHINESE_SIMPLIFIED);
What's the problem? Thanks.

Copying all the resources is a better idea and the reason why there is no default fallback -- you will have complete control over what resources are present and for which language. This is important because resources are merged by default http://download.carrot2.org/head/manual/index.html#section.attribute.kmeans.merge-resources

The most explicit way to solve this would be to copy all all lexical resources to your resources directory. You can find the resource files in Carrot2 Java API distribution, for example.
An alternative is to tell Carrot2 to load the missing resources from the classpath (Carrot2 JAR):
File resourcesDir = new File("resources");
ResourceLookup resourceLookup = new ResourceLookup(
new DirLocator(resourcesDir), // your custom location
new ContextClassLoaderLocator() // fallback: classpath (Carrot2 JAR)
);
LexicalDataLoaderDescriptor.attributeBuilder(attrs)
.resourceLookup(resourceLookup);
In this arrangement, your resources directory can only contain the resources you'd like to override. The non-overridden ones (and the ones that you don't care about) will be loaded from Carrot2 JAR.
There are two caveats here:
When you upgrade Carrot2 JAR, the fallback resources may silently change.
In case of a misconfigured custom location (e.g. passing an empty directory), clustering will silently proceed with built-in lexical resources without any specific warning (unless you use the debug logging level).

Related

ClassLoader::getSystemResource returning null

It used to work in the past, but I don't what happened in the middle, now it returns always null.
The file to read is in the project root diretory, which corresponds to the output of Paths.get(".").
Note: function is top-level
I'm reading the imgui.ini file here
fileLoadToLines(iniFilename)
where it's so defined
fun fileLoadToLines(filename: String) = ClassLoader.getSystemResourceAsStream(filename)?.use { it.bufferedReader().readLines() }
Tried also the other Thread.currentThread().contextClassLoader, no success
What's the problem?
The project root directory is typically the default current working directory, but not necessarily on the classpath. That's why Paths.get(".") returns it, while the classloader doesn't find the file under it, because the latter goes by what's in the classpath.
It used to work probably because you had the project root added to the runtime classpath. The solution I would recommend is instead of using a classloader, just use the file system API in java.io to load it.

How to configure cache folder for SourceDiskCache?

I understand from the documentation that the SourceDiskCache folder cannot be configured using the XML configuration file and is only available "through code installation". However I can't figure out how!
I need to configure a custom folder. I have tried a few different things, with different results (both in Application_Start):
This doesn't throw an error, but uses the default folder (/cache)
var sourceDiskCachePlugin = new SourceDiskCachePlugin {VirtualCacheDir = "~/App_Data/cache"};
Config.Current.Plugins.GetOrInstall(sourceDiskCachePlugin);
This (and most other variations I have tried) throws the error "SourceDiskCache settings may not be adjusted after it is started."
new SourceDiskCachePlugin().Install(Config.Current);
Config.Current.Plugins.Get<SourceDiskCachePlugin>().VirtualCacheDir = "~/App_Data/cache";
How can I configure this?
Also, the documentation states that SourceDiskCache is in beta - is this still the case, and will XML configuration ever be available?
This would be the normal way to configure and install it:
var plugin = new SourceDiskCachePlugin()
plugin.VirtualCacheDir = "~/App_Data/cache";
plugin.Install(Config.Current);
If your code is running more than once, use Config.Current.Plugins.GetOrInstall(plugin); It's best if you only install the plugin during Application_Start.
However, approach #1 from your question should work equally well, as long as you've set the right NTFS permissions on App_Data.

Syntax of Local.Properties In Hybris

I know that local.Properties overrides project.Properties.
I also know that that these files defineā€¦ database connections, ports, build environment, frontend HTTPS, etc.
I further know that project.Properties contains more properties.
Will appreciate if Hybris experts tell me syntax of local.Properties, illustrating with some example.
Please provide correct info.
If we talk about the syntaxes of entries in the project.properties file, then it is key=value
The property files in the hybris are of two types:
The extension level - The property file project.properties is the configuration file that carries properties in the key-value pair for the configurations involved on the extension level For instance, Consider a property in the project.properties of the yacceleratorstorefront (storefront template) extension storefront.storelocator.pageSize.Desktop=10 which clearly indicates the 'StoreLocator' results page size configuration per store. Since the store locator functionality is specific to the storefront and has no relevance for the other modules (like core, facades etc), the property is kept at the extension level.
Please note, project.properties reside in the extension folder
The global level - This is the property file which is the global configuration file, and deals with the properties are extension agnostic and carry a global impact. For instance the property commerceservices.default.desktop.ui.experience=responsive sets the ui experience to responsive mode that specifies the deployment to be for the responsive format.
The local.property file supersedes all of the properties with the same key that is defined in any of the project.proprties.
Please note, the local.properties file reside in the hybris/config folder
The hybris registry creates a property configuration map which constitutes all of the properties mentioned in the deployment configuration. The same could be managed in the HAC under platform/configuration.
The clear intent of the local.proprties file is to have information which either requires to be overriden on a global level. The override may be of different types, e.g. cart expiry time could be made different on different environments by the use of the local.property files.
For further reading, please refer to the link: https://wiki.hybris.com/display/release5/Configuring+the+Behavior+of+the+hybris+Commerce+Suite
property call hierarchy (from primary to secondary):
java -Dproperty.key=something
hybris/config/local.properties
hybris/*/(extension-name)/project.properties
hybris/bin/platform/project.properties
and within java code:
configService.getString("property.key", "last fallback value, if no propertyfile provide this key");
You could review all current variables using the hac interface for properties: http://localhost:9001/platform/config

Resource Files in CF - Not Embedded

I have a PPC2003 project in VS2005. I have added a resource file (SomeResources.resx) to the project. I can access the test string I have in the file by using My.Resources.SomeResources.MyTestString (I am using the default Custom Tool Name that VS provides).
When the Build Action property of the is set to Embedded Resource, the application references the MyTestString successfully.
But I do not want to embed the file, so that it's string values can be modified after it has been deployed/installed.
I, therefore, changed the Build Action to Content, so that the file gets copied out to the device for potential future manipulation. When I call MyTestString I get the following error:
MissingManifestResourceException Stack Trace: at System.Resources.ResourceManager.InternalGetResourceSet() at System.Resources.ResourceManager.InternalGetResourceSet() at System.Resources.ResourceManager.InternalGetResourceSet() at System.Resources.ResourceManager.GetString() at MyApp.My.Resources.SomeResources.get_MyTestString() at MyApp.fMain.fMain_Load() at System.Windows.Forms.Form.OnLoad() at System.Windows.Forms.Form._SetVisibleNotify() at System.Windows.Forms.Control.set_Visible() at System.Windows.Forms.Application.Run() at MyApp.fMain.Main()
As the file is not embedded, do I maybe need to manually load it first? If so, how? Any other ideas? Is it not possible to do what I'm after achieving and should I just create my own XML file/reader?
Resources (resx files) are specifically designed to be compiled into the application. If you want it to be an editable content file on the target, then you have to approach it differently and use something like an XML file and wrap that with accessors (akin to the Configuration namespace stuff in the full framework).

How to update the JSF2.0 (Primefaces) tooltips dynamically without server restart

I need to update the JSF2.0 (Primefaces) tooltips dynamically without server restart.
Meaning need to find a way where tooltips (atm from properties file) of the a running application can be changed without requiring a server restart.
We are running websphere and deploying a non exploded EAR (can probably convince to deploy exploded war)
Any Ideas or tips please. Thanks you
The value attribute of the p:toolTip component must be an EL expression or a literal text. Usually, one would reference a resource bundle declared using the var attribute of the f:loadBundle tag, in the EL expression for the tooltip.
The underlying resource bundle declared using the basename attribute could be backed by a property file itself (in which case you need to place the property file in the appropriate directory on the classpath), or for that matter it could be a custom ResourceBundle implementation that could read from a properties file (located outside the container), or a database or any store for that matter.
You could therefore change your existing EL expression from the existing one defined as:
<f:loadBundle var="msg" basename="propfile_location" />
to
<f:loadBundle var="msg" basename="fully qualified class name of the ResourceBundle class" />
In simpler words, you will need to roll your own ResourceBundle class(es) to support the various locales. Needless to state, but you will need to override the ResourceBundle.getObject(java.lang.String) method, as it is invoked by the ResourceBundleELResolver implementation when evaluating the EL expressions referencing ResourceBundles.
Additionally, you will need to ensure that the ResourceBundle.getObject(java.lang.String) implementation of your ResourceBundle will always re-fetch and return the value corresponding to the provided key. Failure to ensure this would mean that the initial value fetched by the resource bundle may be returned on subsequent invocations, especially if you are caching the initial value. You are likely to encounter this behavior even if you deploy an exploded WAR file where you can modify the property file contents without a redeployment of the application, and that is why it is important to use a custom ResourceBundle implementation that does not cache values.