i have problem calling lucene method in php.
im beginner in java.
n im searching in google 4 solving, but no found.
im trying write this java code to php using php java bridge.
http://www.lucenetutorial.com/lucene-in-5-minutes.html
i found this line that i dont get it how to make it to php:
IndexReader reader = DirectoryReader.open(index);
DirectoryReader has no 'new' for initial a object, that's what i dont get it to write in php.
but, if the java code like below,
Query q = new QueryParser(Version.LUCENE_43, "content", analyzer).parse(querystr);
i write like this:
$query = new Query\QueryParser($version->LUCENE_43,'content',$analyzer);
$query->parse($strquery);
n no error.
so, how to create this java code
IndexReader reader = DirectoryReader.open(index);
to php ??
really need help,
thanks a lot in advance.
You should be able to use Zend's Zend_Search_Lucene module rather than using the PHP-Java bridge directly. Check it out it may be much more easier.
Can you reference to where you read that it'd be slower? What measurements were taken and how was this done? I am not really sure that, whatever these performance implications, they'd have a noticeable impact on our application.
Also since you're using Symfony there are ready libraries that provide integration for Symfony and Symfony2. I really suggest using Zend Search Lucene especially if you don't have JAVA experience since basing your application on more than one technology is already complex enough.
Another useful thing that may come in handy is a Lucene/Sorl query builder. I know that I am not answering your exact technical question however being a PHP programmer and having experience with Sorl/Lucene I just wanted to point out the issues above so that you can take the appropriate decision.
Related
Basically, what I am asking is, how does a java based program with free chat gaurd against, "); String onlinejava = "exploits by closing the string."
Pretty simple: they don't need to. Java is a compiler-language, thus the code can't be modified by this kind of exploits. This can only be done in some interpreter-languages, or before the code is compiled, like in SQL.
I have Java code that uses Expect4j. However, I need to rewrite this code into Python. And so I found Pexpect. Now, I am not really sure how to use any of these and were wondering if anybody could help me with that.
As I understand, the Java version usually begins like
channel = (ChannelShell) session.openChannel("shell")
Expect4j expect = new Expect4j(channel.getInputStream(), channel.getOutputStream());
channel.connect();
How would this code look in Python? I have been looking for a few days now and am not really understanding it. I really haven't tried much because I feel like I'm stuck. For connecting to SSH I am going to use paramiko (which I guess solves the very first line of code above)
I'm attempting to read and write an object through gson. Early in the project this was completely viable and doing great, but as I wrote more data for that object I eventually ran across something along the lines of this:
I can't seem to grab the full stacktrack seeing as it overflows my console within milliseconds, but I've pastebinned everything my console could grab: http://pastebin.com/v36d5qua
If there is a solution to this, or possibly just a better api for this purpose I would really appreciate some advice.
Current usage: http://pastebin.com/2Yk2v0Tm
GsonUtil.save(player, Player.class, new File("./resources/players/"+player.getId()+".json"));
P.S I'm new to java & this site in general, if I have misleading tags, title etc please let me know.
Don't use gson. It's slow, it's buggy, it's inconvenient to use. Just use org.json - http://theoryapp.com/parse-json-in-java/
I'm working in a project which needs to export EHR information in CCR format. I must use Java. The problem that I'm facing is that I can't find an easy way to do it.
The better way to do what I'm doing would be to export as CDA using something like CDAPI but it's overly expensive (30k/year) and complicated. However it shows an example of what I'd like. Something like:
CCR ccr = new CCR();
...
out.print(ccr.toString()); // Returns XML
But it's as if this doesn't exist.
There's CCR4J but it can only read XML files and make Java objects. Not the other way around.
There's Google Health (now discontinued) which might have what I'm looking for, but I can't even figure out how to use it.
There's CCR Binder which has some convenience methods for creating CCR XML from code built on top of Google Health API, but I can't figure out how to use that either.
I could also just read the ASTM CCR Spec and implement something on my own which at this point begins to look like the faster option.
Now I would really like to stay away from Google Health. Seems to be an overkill for my task as is exporting do CDA. Any comments and suggestions are appreciated.
Just for the benefit of people searching for the same info. Here's the CCR Spec.
Sorry for this (very) late answer, but i stumbled uppon this post, cause it's still ranked high in Google if you search for java and CCR. To prevent others from giving up to quick I have to correct you:
With CCR4J you CAN create CCRs from Java Objects (since 2008) and it works like a charm! Not just parsing it from a given file.
Perhaps you just didn't got how to use the library back in time?
So here's a little Example (no valid CCR!) for the next one, who stumble over this post trying to create a CCR with this library:
//New XML-Document
ContinuityOfCareRecordDocument newDoc = ContinuityOfCareRecordDocument.Factory.newInstance();
//New CCR
ContinuityOfCareRecord newCCR = ContinuityOfCareRecord.Factory.newInstance();
//Add Object ID
newCCR.setCCRDocumentObjectID("asdasdbdffdjg343204dsss3490");
//Add new Language
newCCR.addNewLanguage().setText("English");
//Add new Body
newCCR.addNewBody();
//Add new Problem with Code
newCCR.getBody().addNewProblems().addNewProblem().addNewDescription().addNewCode().setCodingSystem("ICD");
newCCR.getBody().getProblems().getProblemArray(0).getDescription().getCodeArray(0).setValue("1225-55558");
//Add CCR to document and save
newDoc.setContinuityOfCareRecord(newCCR);
newDoc.save(new File("My-Generated-CCR.xml"));
I ended up doing something like this:
Video: Quick and Dirty CCR
To summarize: Use JAXB to make the classes them marshall them using JAXB marshaller.
I'm porting a small (<10 classes) C++ project to Java. The project manipulates sound files, and in C++ does this using libsndfile. The code includes stuff like:
const int channels = audioFileInfo.channels;
...
sf_readf_double( audioFile, inputBuffer, MAX_ECHO );
...
sf_writef_double( outputAudioFile, ¤tAudioBuffer[WINDOW_SIZE * channels], SEGMENTATION_LENGTH );
In Java, what's the best way to manipulate sound files on a low level? I'm talking about stuff like normalizing, adding echoes etc.
Progress Report
After a bit of digging I've found javax.sound.sampled, which looks like it might do the job.
Edit 2 On closer inspection, it won't work (or at least not in any usable way), since it relies on the com.sun.sound package.
Edit 3 On even more inspection, and experimentation, the com.sun.sound and sun.misc packages are released under the GNU GPLv2, and I've downloaded them into my project. Having renamed javax.sound.sampled to imp.javax.sound.sampled, the project compiles, and I can create AudioFileFormat objects without any exceptions being thrown, yet. I haven't had a chance to play around much yet but I'll keep you updated.
Edit 4 Ok, Some things appear to work with javax.sound.sampled, others do not. For example, calls such as:
AudioInputStream stream = AudioSystem.getAudioInputStream(waveFile));
do not work, however I can get around this by doing:
WaveFileReader wfr = new WaveFileReader();
AudioInputStream stream = wfr.getAudioInputStream(waveFile);
In general, calls to things like AudioSystem.getAudioFileTypes() return empty lists. I can delve into the packages and see it's something to do with providers, but I'm at a loss how to remedy this. Having got my stream object it does report its encoding etc. correctly, which is encouraging.
My big problem at the moment is creating a Clip object. This needs to be created with a Line object, which would normally come from AudioSystem. Can anyone think of a way around this?
libsndfile can be compiled for Android using the Native Development Kit. Once you have the library compiled for Android, you should be able to use JNI to access it from Java.
Why don't you just keep this code in C++ and invoke it in your Java through JNI ?
If you can port libsndfile using the NDK, why not just use the NDK to port your C++ code directly and not worry about porting it to java?