ANY23-321 Add openie toggle functionality to service
Project: http://git-wip-us.apache.org/repos/asf/any23/repo Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/71bf171a Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/71bf171a Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/71bf171a Branch: refs/heads/master Commit: 71bf171a3b64fbb0388373aabad645e812bf3a0f Parents: b3806d3 Author: Lewis John McGibbney <[email protected]> Authored: Tue Feb 27 10:11:57 2018 -0800 Committer: Lewis John McGibbney <[email protected]> Committed: Tue Feb 27 10:11:57 2018 -0800 ---------------------------------------------------------------------- .../plugin/extractor/openie/OpenIEExtractor.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/any23/blob/71bf171a/plugins/openie/src/main/java/org/apache/any23/plugin/extractor/openie/OpenIEExtractor.java ---------------------------------------------------------------------- diff --git a/plugins/openie/src/main/java/org/apache/any23/plugin/extractor/openie/OpenIEExtractor.java b/plugins/openie/src/main/java/org/apache/any23/plugin/extractor/openie/OpenIEExtractor.java index 1b6a9cf..d02b5a2 100644 --- a/plugins/openie/src/main/java/org/apache/any23/plugin/extractor/openie/OpenIEExtractor.java +++ b/plugins/openie/src/main/java/org/apache/any23/plugin/extractor/openie/OpenIEExtractor.java @@ -23,13 +23,12 @@ import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerFactoryConfigurationError; import org.apache.any23.extractor.Extractor; +import org.apache.any23.extractor.IssueReport; import org.apache.any23.configuration.Configuration; import org.apache.any23.configuration.DefaultConfiguration; import org.apache.any23.extractor.ExtractionContext; import org.apache.any23.extractor.ExtractorDescription; -import org.apache.any23.extractor.ExtractorFactory; import org.apache.any23.plugin.Author; -import org.apache.any23.plugin.ExtractorPlugin; import org.apache.any23.rdf.RDFUtils; import org.apache.any23.util.StreamUtils; import org.apache.tika.Tika; @@ -63,7 +62,7 @@ import scala.collection.Seq; * sentences representing relations in the text. */ @Author(name="Lewis John McGibbney ([email protected])") -public class OpenIEExtractor implements Extractor.TagSoupDOMExtractor, ExtractorPlugin { +public class OpenIEExtractor implements Extractor.TagSoupDOMExtractor { private static final Logger LOG = LoggerFactory.getLogger(OpenIEExtractor.class); @@ -106,7 +105,13 @@ public class OpenIEExtractor implements Extractor.TagSoupDOMExtractor, Extractor LOG.error("Encountered error during OpenIE extraction.", e); } catch (TikaException e) { LOG.error("Encountered error whilst parsing InputStream with Tika.", e); - } + } catch (OutOfMemoryError e) { + //let the gc do its thing + openIE = null; + out.notifyIssue(IssueReport.IssueLevel.FATAL, "Not enough memory available to perform OpenIE extraction.", -1, -1); + LOG.error("Encountered OutOfMemoryError... increase JVM heap when running OpenIEExtractor.", e); + return; + } List<Instance> listExtractions = JavaConversions.seqAsJavaList(extractions); // for each extraction instance we can obtain a number of extraction elements @@ -129,9 +134,4 @@ public class OpenIEExtractor implements Extractor.TagSoupDOMExtractor, Extractor } } } - - @Override - public ExtractorFactory<?> getExtractorFactory() { - return (ExtractorFactory<?>) OpenIEExtractorFactory.getDescriptionInstance(); - } }
