Lucene numDocs and doqFreq on custom similarity class - lucene

im doing an aplication with Lucene (im a noob with it) and im facing some problems.
My aplication uses the Lucene 2.4.0 library with a custom similaraty implementation (the jar is imported)
In my app im calculating doqFreq and numDocs manually (im adding the values of all indexes and then i calculate a global value in order to use it on every query) and i want to use that values on a custom similarity implementation in order to calculate a new IDF.
The problem is that I dont know how to use (or send) the new doqFreq and numDocs values from my app on that new similarty implementation as I dont want to change luceneĀ“s code apart from this extra class.
Any suggestions or examples? I read the docs but i dont now how to aproach this :s
Thanks

You can try extending IndexReader and overriding IndexReader.docFreq() and IndexReader.numDocs(). In this subtype you can supply that you are calculating manually. I'm not sure if there are other Lucene components that are dependent on those values, so you might want to tread carefully here.

Related

Projecting an instance from a A4Solution

I'm trying to make a new UI to visualize my Alloy instances. I've got an A4Solution and have been successful in extracting atoms, relations, checking atom signatures BUT I can't seem to understand how to project the instance on some sig.
I've noticed that I can try to use the edu.mit.csail.sdg.alloy4viz.AlloyInstance, I've got options to project there, but that'd imply in starting over, from a different angle.
Would that be the way to go? I'd prefer to extract that from the A4Solution object.
Thanks
You might want to look at the edu.mit.csail.sdg.alloy4viz.StaticProjector class and its project methods---that's how the Alloy Visualizer implements projections. If your visualization uses the edu.mit.csail.sdg.alloy4viz.AlloyModel class, you should be able to reuse the existing code in StaticProjector; from your post it seems, however, that you'd prefer not use any of the alloy4viz classes, in which case it should not be too difficult to understand how StaticProjector works and reapply the same ideas to your project. Or you could convert an A4Solution object to an AlloyInstance[1] and build your visualizer around the alloy4viz classes, which, in my opinion, would be a good way to go about your project.
[1] something like:
a4sol.writeXML("instance.xml")
AlloyInstance inst = StaticInstanceReader.parseInstance(new File("instance.xml"));

How can my own implementation of Find References write to the Eclipse Search View?

I am using the Eclipse plugin framework to write an editor for a specific language. I would like to implement a Find Reference capability for this language and write the results to the eclipse Search View. I've been searching the web for a few days now, and all I found was explanations on how the define the org.eclipse.search.searchResultViewPages extension point and define a search page and a search view. I am only interested in the Search View and how I can plug in my own results to it.
Thanks!
I have started to work on the same problem.
For me, the easiest thing to do was to add a command handler for the existing Java find references command org.eclipse.jdt.ui.edit.text.java.search.references.in.workspace when in the context of my editor.
The current version of my handler is very simple, and it sends a regular expression based on the current word to a simple text search (admittedly, producing false positives). On the plus side, the results get plugged into the search results as you would like, and I didn't have to deal with search views.
The important thing seems to be that your handler end with a call like this:
NewSearchUI.runQueryInBackground(query);
In order to prepare my simple text query, I use
ISearchQuery query = TextSearchQueryProvider.getPreferred().createQuery(new PigSearchInput(word));
You can look at my complete handler class here. It's mostly self contained. In the future I plan on implementing a "real" find references feature,, using my own classes instead of the Eclipse text search ones, but I haven't done this yet.

Accessing model attribute from css/less file with Rails 3

The project I'm working on requires me to adapt the size of the elements on screen according to per-user setting. We're using Twitter bootstrap, so my first idea was to toy with the #basefont value, and it seems to do the trick.
However, I don't know how to access the user setting from the .less file. I tried using erb with .less.erb, but it looks like I don't have access to any code in my application.
Is there a way to get the value I'm looking for from the .less file, or - even better - a proper way to do this ?
Thanks for your time.
EDIT
Since I need to get the value at runtime, the way I tried won't work anyway, though I'm still interested on an answer. The only way I see to do what I want is to add a class according to the user setting. Again, I'd be glad to have alternatives.
I opted for css3 transform (and vendors implementation) property. It does the job, but seems to hit the GPU quite a lot. So still open to other answers. :)

Dynamic Magento Grid built with database query

This is my first time asking a question here so, be nice;p .. I'm working with Magento (and Zend Framework) for the first time and I'm trying to build a custom grid that will populate based off of a manually written query. I'm trying to extend the Mage_Core_Model_Mysql4_Collection_Abstract to allow a query to be loaded into it and then parse the select fields in the extended Grid class to make it dynamic... Is this even possible or am I beating a dead horse? I've been at it for a week now and I'm not getting anywhere. The problem seems to be that inside the __Model_mysql4_Collection class has to be initialized with a resource model using _init() in the constuct
As a learning exercise use the module creator to make an admin grid page and see how that is done. Or even modify it's output to get what you need.
There will be a grid container block, a grid block (with _prepareCollection and _prepareColumns methods), a model, a resource model (representing a single record) and a collection resource model (representing several records).
Providing your own _init methods shouldn't be any sort of problem. Perhaps you'd like to post your config.xml and code so far as a pastebin or something.

Is it possible to access custom properties from QT Designer after converting to python?

I am new to PyQt and Qt Designer and I'm trying to create an easy method for relating qWidgets with the tables and columns in an SQLite database. My idea was to tag each qWidget in designer with two custom properties, one with the table name and one with the column name. Later, I would use the info provided by designer to build my own class which creates a relationship between the qwidets and SQLite database.
Adding the custom properties in Designer seems to work fine however, the code for these custom properties do not get generated when converting the xml of designer into python (using UIC). Has anyone done this successfully? Perhaps there is a better way to do this?
Thanks,
Eric
If you added a property in Designer called "myproperty", fetch it with...
mywidget.property("myproperty")
This works fine in pyqt 4.8.3, perhaps it did not work in previous versions.
Check out this article Eric. Particularly look at the section titled "Producing a Plugin." River Bank Computing has another great PyQt reference.
EDIT:
I've been doing some more reading and I can't find a way to have this done automatically for you. If you are ok with with adding dynamic properties at run-time instead of design time you could accomplish the same end result. Here is an explanation of the setProperty() method in QObject, from which QWidget inherits.
If that doesn't work for you then it seems you might be better off going with a less generic approach. Instead of using a generic QWidget, you might be able to use a custom class derived from QSqlTableModel to keep track of your connection info. Another way would be to just use a QTableView and do the queries yourself to populate the data. Here and here are articles on databases in Qt. You might some inspiration for a new design from one of them.
I have not had great luck with using the Designer tool -- usually I end up doing a few rough layout, using pyuic and then editing and adding other stuff by hand.
It sounds like you could easily accomplish your task by creating your own custom class that inherits from QWidget and has the additional properties that you described. With my experiences trying to use custom widgets in the designer, I think the 'easier' way is to just write the class yourself and then set the layout by hand.
I know this doesn't exactly answer your question, but maybe you will try some of my suggestions.