Skip to content

Commit

Permalink
Rename Answer to ExtractAnswer
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-grella committed Nov 8, 2023
1 parent be5ba0b commit 31d2aba
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/questionanswering/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func main() {

fn := func(text string) error {
start := time.Now()
result, err := m.Answer(context.Background(), text, content, opts)
result, err := m.ExtractAnswer(context.Background(), text, content, opts)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/client_questionanswering.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func NewClientForQuestionAnswering(target string, opts Options) questionanswerin
}
}

// Answer answers the given question.
func (c *clientForQuestionAnswering) Answer(ctx context.Context, question, passage string, opts *questionanswering.Options) (questionanswering.Response, error) {
// ExtractAnswer answers the given question.
func (c *clientForQuestionAnswering) ExtractAnswer(ctx context.Context, question, passage string, opts *questionanswering.Options) (questionanswering.Response, error) {
if opts == nil {
opts = &questionanswering.Options{}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "google/api/annotations.proto";
option go_package = "github.com/nlpodyssey/cybertron/pkg/server/apis/questionanswering/v1;questionansweringv1";

service QuestionAnsweringService {
rpc Answer(AnswerRequest) returns (AnswerResponse) {
rpc ExtractAnswer(AnswerRequest) returns (AnswerResponse) {
option (google.api.http) = {
post: "/v1/answer"
body: "*"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/server/server_questionanswering.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func (s *serverForQuestionAnswering) RegisterHandlerServer(ctx context.Context,
return questionansweringv1.RegisterQuestionAnsweringServiceHandlerServer(ctx, mux, s)
}

// Answer handles the Answer request.
func (s *serverForQuestionAnswering) Answer(ctx context.Context, req *questionansweringv1.AnswerRequest) (*questionansweringv1.AnswerResponse, error) {
// ExtractAnswer handles the Answer request.
func (s *serverForQuestionAnswering) ExtractAnswer(ctx context.Context, req *questionansweringv1.AnswerRequest) (*questionansweringv1.AnswerResponse, error) {
params := req.GetOptions()
opts := &questionanswering.Options{
MaxAnswers: int(params.GetMaxAnswers()),
Expand All @@ -42,7 +42,7 @@ func (s *serverForQuestionAnswering) Answer(ctx context.Context, req *questionan
MaxCandidates: int(params.GetMaxCandidates()),
}

result, err := s.engine.Answer(ctx, req.GetQuestion(), req.GetPassage(), opts)
result, err := s.engine.ExtractAnswer(ctx, req.GetQuestion(), req.GetPassage(), opts)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/tasks/questionanswering/bert/questionanswering.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func LoadQuestionAnswering(modelPath string) (*QuestionAnswering, error) {
}, nil
}

// Answer returns the answers for the given question and passage.
// ExtractAnswer returns the answers for the given question and passage.
// The options may assume default values if those are not set.
func (qa *QuestionAnswering) Answer(_ context.Context, question string, passage string, opts *questionanswering.Options) (questionanswering.Response, error) {
func (qa *QuestionAnswering) ExtractAnswer(_ context.Context, question string, passage string, opts *questionanswering.Options) (questionanswering.Response, error) {
checkOptions(opts)

qt, pt := qa.tokenize(question, passage)
Expand Down
2 changes: 1 addition & 1 deletion pkg/tasks/questionanswering/questionanswering.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var ErrInputSequenceTooLong = errors.New("input sequence too long")

// Interface defines the main functions for question-answering task.
type Interface interface {
Answer(ctx context.Context, question string, passage string, opts *Options) (Response, error)
ExtractAnswer(ctx context.Context, question string, passage string, opts *Options) (Response, error)
}

// Options defines the options for question-answering task.
Expand Down

0 comments on commit 31d2aba

Please sign in to comment.