Skip to content

Commit

Permalink
[#41] standardise aspects key from input batch
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondng76 committed Jan 17, 2022
1 parent 038e660 commit d1a366f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion demo_api/sentic_gcn/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def predict():
req_body = request.get_json()

# Preprocessing
processed_inputs, processed_indices = preprocessor(req_body)
processed_inputs, processed_indices = preprocessor([req_body])
outputs = model(processed_indices)

# Postprocessing
Expand Down
12 changes: 6 additions & 6 deletions docs/source/model/senticgcn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ following code:
inputs = [
{
"aspect": ["Soup"],
"aspects": ["Soup"],
"sentence": "The soup is a little salty."
},
{
"aspect": ["service"],
"aspects": ["service"],
"sentence": """Everyone that sat in the back outside agreed that it was the worst service we
had ever received."""
},
{
"aspect": ["location", "food"],
"aspects": ["location", "food"],
"sentence": """it 's located in a strip mall near the beverly center , not the greatest
location , but the food keeps me coming back for more ."""
}
Expand Down Expand Up @@ -152,16 +152,16 @@ with the following code:
inputs = [
{
"aspect": ["Soup"],
"aspects": ["Soup"],
"sentence": "The soup is a little salty."
},
{
"aspect": ["service"],
"aspects": ["service"],
"sentence": """Everyone that sat in the back outside agreed that it was the worst service we
had ever received."""
},
{
"aspect": ["location", "food"],
"aspects": ["location", "food"],
"sentence": """it 's located in a strip mall near the beverly center , not the greatest
location , but the food keeps me coming back for more ."""
}
Expand Down
4 changes: 2 additions & 2 deletions sgnlp/models/sentic_gcn/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def _process_inputs(self, data_batch: List[Dict[str, Union[str, List[str]]]]) ->
for batch in data_batch:
full_text = batch["sentence"].lower().strip()
full_text_tokens = batch["sentence"].split()
for aspect in batch["aspect"]:
for aspect in batch["aspects"]:
aspect = aspect.lower().strip()
aspect_token_indexes = [
idx
Expand Down Expand Up @@ -481,7 +481,7 @@ def _process_inputs(self, data_batch: List[Dict[str, Union[str, List[str]]]]) ->
for batch in data_batch:
full_text = batch["sentence"].lower().strip()
full_text_tokens = batch["sentence"].split()
for aspect in batch["aspect"]:
for aspect in batch["aspects"]:
aspect = aspect.lower().strip()
aspect_token_indexes = [
idx
Expand Down

0 comments on commit d1a366f

Please sign in to comment.