sentence_input_batch.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2017 Google Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // =============================================================================
  15. #ifndef NLP_SAFT_OPENSOURCE_DRAGNN_IO_SENTENCE_INPUT_BATCH_H_
  16. #define NLP_SAFT_OPENSOURCE_DRAGNN_IO_SENTENCE_INPUT_BATCH_H_
  17. #include <string>
  18. #include <vector>
  19. #include "dragnn/core/interfaces/input_batch.h"
  20. #include "dragnn/io/syntaxnet_sentence.h"
  21. #include "syntaxnet/base.h"
  22. namespace syntaxnet {
  23. namespace dragnn {
  24. // Data accessor backed by a syntaxnet::Sentence object.
  25. class SentenceInputBatch : public InputBatch {
  26. public:
  27. SentenceInputBatch() {}
  28. // Translates from a vector of stringified Sentence protos.
  29. void SetData(
  30. const std::vector<string> &stringified_sentence_protos) override;
  31. // Translates to a vector of stringified Sentence protos.
  32. const std::vector<string> GetSerializedData() const override;
  33. // Get the underlying Sentences.
  34. std::vector<SyntaxNetSentence> *data() { return &data_; }
  35. private:
  36. // The backing Sentence protos.
  37. std::vector<SyntaxNetSentence> data_;
  38. };
  39. } // namespace dragnn
  40. } // namespace syntaxnet
  41. #endif // NLP_SAFT_OPENSOURCE_DRAGNN_IO_SENTENCE_INPUT_BATCH_H_