void RDFParserSerd::doParse(const char *fileName, const char *baseUri, RDFNotation notation, bool ignoreErrors, RDFCallback *callback) { this->callback = callback; this->numByte = fileUtil::getSize(fileName); // Create Base URI and environment SerdURI base_uri = SERD_URI_NULL; SerdNode base = serd_node_new_file_uri((const uint8_t *)fileName, NULL, &base_uri, false); env = serd_env_new(&base); SerdReader* reader = serd_reader_new( getParserType(notation), this, NULL, (SerdBaseSink)hdtserd_basechanged, (SerdPrefixSink)hdtserd_prefixchanged, (SerdStatementSink)hdtserd_process_triple, (SerdEndSink)hdtserd_end); serd_reader_set_error_sink(reader, hdtserd_error, NULL); const uint8_t* input=serd_uri_to_path((const uint8_t *)fileName); FILE *in_fd = fopen((const char*)input, "r"); // TODO: fadvise sequential if(in_fd==NULL) { throw "Could not open input file for parsing"; } SerdStatus status = serd_reader_read_file_handle(reader, in_fd, (const uint8_t *)fileName); serd_reader_free(reader); fclose(in_fd); serd_env_free(env); serd_node_free(&base); }
void ParserModel::validateArtifactMap() throw(InvalidFormatException) { BaseModel::validateArtifactMap(); if (!(dynamic_cast<AbstractModel*>(artifactMap->get(BUILD_MODEL_ENTRY_NAME)) != 0)) { throw InvalidFormatException("Missing the build model!"); } ParserType modelType = getParserType(); if (modelType != 0) { if (CHUNKING::equals(modelType)) { if (artifactMap->get(ATTACH_MODEL_ENTRY_NAME) != 0) throw InvalidFormatException("attachModel must be null for chunking parser!"); } else if (TREEINSERT::equals(modelType)) { if (!(dynamic_cast<AbstractModel*>(artifactMap->get(ATTACH_MODEL_ENTRY_NAME)) != 0)) throw InvalidFormatException("attachModel must not be null!"); } else { throw InvalidFormatException("Unkown ParserType!"); } } else { throw InvalidFormatException("Missing the parser type property!"); } if (!(dynamic_cast<AbstractModel*>(artifactMap->get(CHECK_MODEL_ENTRY_NAME)) != 0)) { throw InvalidFormatException("Missing the check model!"); } if (!(dynamic_cast<POSModel*>(artifactMap->get(PARSER_TAGGER_MODEL_ENTRY_NAME)) != 0)) { throw InvalidFormatException("Missing the tagger model!"); } if (!(dynamic_cast<ChunkerModel*>(artifactMap->get(CHUNKER_TAGGER_MODEL_ENTRY_NAME)) != 0)) { throw InvalidFormatException("Missing the chunker model!"); } if (!(dynamic_cast<HeadRules*>(artifactMap->get(HEAD_RULES_MODEL_ENTRY_NAME)) != 0)) { throw InvalidFormatException("Missing the head rules!"); } }
opennlp::tools::parser::ParserModel *ParserModel::updateChunkerModel(ChunkerModel *chunkModel) { return new ParserModel(getLanguage(), getBuildModel(), getCheckModel(), getAttachModel(), getParserTaggerModel(), chunkModel, getHeadRules(), getParserType()); }