Date
1 - 4 of 4
Java null pointer error with coreNLP
Hello
I am having problems accessing the ‘dependencies’ feature of a token using core nlp. If anyone could provide some advice as to why the NullPointerException that would be much appreciated. I am using GATE 8.5.1 on MacOSX. Many thanks I have the following error message: java.lang.NullPointerException at GetTokenDepsPhase.attempt(file:/Users/rorylamrock/Work/text-engine-v.2/ANNIE/NE/lode%20v1%20jape/post_processing/attempt_with_dependencies.jape:57) at gate.jape.RightHandSide.transduce(RightHandSide.java:344) at gate.jape.SinglePhaseTransducer.fireRule(SinglePhaseTransducer.java:743) at gate.jape.SinglePhaseTransducer.transduce(SinglePhaseTransducer.java:354) at gate.jape.MultiPhaseTransducer.transduce(MultiPhaseTransducer.java:188) at gate.jape.Batch.transduce(Batch.java:203) at gate.creole.Transducer.execute(Transducer.java:177) at gate.util.Benchmark.executeWithBenchmarking(Benchmark.java:291) at gate.creole.ConditionalSerialController.runComponent(ConditionalSerialController.java:172) at gate.creole.SerialController.executeImpl(SerialController.java:157) at gate.creole.ConditionalSerialAnalyserController.executeImpl(ConditionalSerialAnalyserController.java:225) at gate.creole.ConditionalSerialAnalyserController.execute(ConditionalSerialAnalyserController.java:132) at gate.util.Benchmark.executeWithBenchmarking(Benchmark.java:291) at gate.gui.SerialControllerEditor$RunAction$1.run(SerialControllerEditor.java:1759) at java.lang.Thread.run(Thread.java:748) I am using the following imports Imports: { import static gate.Utils.*; import gate.stanford.DependencyRelation; } Below is the problematic part of the RHS. Changing ‘dependencies’ to ‘category’ works to get the token category. I don’t know why the dependency features are throwing an error? for (Annotation token : tokens.inDocumentOrder()) { FeatureMap lookupFeatures = token.getFeatures(); deps = token.getFeatures().get("dependencies").toString(); } |
|
Mark Greenwood
I'm guessing not every token has the dependency feature, so you'll need to check that it exists (i.e isn't null) before you dereference it with the call of to string() Mark On Sat, 9 Jun 2018, 15:23 Rory Lamrock via Groups.Io, <rorylamrock=yahoo.co.uk@groups.io> wrote: Hello |
|
Ian Roberts
Or use String.valueOf(x) instead of x.toString(), which is the same in cases where x is not null but gives the four letter string “null” when x is null. Ian On Sat, 9 Jun 2018 at 15:26, Mark Greenwood <m.a.greenwood@...> wrote:
|
|
fh2947
Many thanks, those both worked but I now get different java errors.
toggle quoted message
Show quoted text
I think I may have surpassed my limited java knowledge and may need some freelance support to help - can you recommend anyone I could contact on a paid basis to take a look at my application and assist with some additional programming?
|
|