Skip to content
This repository has been archived by the owner on Dec 2, 2019. It is now read-only.

Commit

Permalink
Merge cd5aab2 into 81287cc
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch committed Jun 19, 2019
2 parents 81287cc + cd5aab2 commit e8a43cc
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/app/_models/parse-result.ts
Expand Up @@ -11,6 +11,7 @@ export class IngredientResult {
constructor(
public ingredientRaw?: string,
public ingredientParsed?: IngredientParsed,
public confidence?: number,
public error?: string) { }
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/_pipes/js-example.pipe.ts
Expand Up @@ -22,7 +22,6 @@ fetch("${backendUrl}/parseIngredients", {
})
}).then(
function(response) {
// Check for successful response from Zestful server.
if (response.status !== 200) {
console.log('Error talking to Zestful server: ' + response.status);
Expand Down Expand Up @@ -54,7 +53,8 @@ fetch("${backendUrl}/parseIngredients", {
console.log(\`Unit: \$\{parsed.unit\}\`);
console.log(\`Product Size Modifier: \$\{parsed.productSizeModifier\}\`);
console.log(\`Product: \$\{parsed.product\}\`);
console.log(\`Preparation: \$\{parsed.preparationNotes\}\`);
console.log(\`Preparation Notes: \$\{parsed.preparationNotes\}\`);
console.log(\`Confidence: \$\{result.confidence\}\`);
});
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/public/demo/demo.component.html
Expand Up @@ -43,6 +43,10 @@ <h1>Developer Demo</h1>
<mat-card-subtitle>preparation instructions</mat-card-subtitle>
</mat-card>
</div>
<mat-card *ngIf="confidence" class="confidence-card">
<mat-card-title>{{ (confidence * 100.0) | number:'1.1-2' }}%</mat-card-title>
<mat-card-subtitle>confidence</mat-card-subtitle>
</mat-card>
<div *ngIf="requestsRemaining !== null" class="top-level">
<span class="fieldName">Requests remaining</span>: {{ requestsRemaining }}
</div>
Expand Down
10 changes: 9 additions & 1 deletion src/app/public/demo/demo.component.scss
Expand Up @@ -63,13 +63,21 @@ div.result-cards {
}
}

mat-card {
.result-cards mat-card {
margin-right: 25px;
@include respond-to('medium') {
margin-right: 2px;
}
}

.confidence-card {
max-width: 120px;
@include respond-to('medium') {
max-width: inherit;
}
background: rgb(177, 241, 250);
}

mat-expansion-panel {
margin-top: 50px;
min-width: 150px;
Expand Down
6 changes: 5 additions & 1 deletion src/app/public/demo/demo.component.ts
Expand Up @@ -15,12 +15,13 @@ export class DemoComponent implements OnInit {
ingredientRaw: string;
isWaitingForParseResult: boolean = false;
ingredientParsed: IngredientParsed;
confidence: number;
error: string;
requestsRemaining: number = null;
curlExample: string = null;
jsExample: string = null;
readonly exampleInputs: string[] = [
'1 1/2 cups finely chopped red onions',
'2 1/2 tablespoons finely chopped parsley',
'½ tsp brown sugar',
'3 large Granny Smith apples',
];
Expand All @@ -45,9 +46,11 @@ export class DemoComponent implements OnInit {
const parseResult = response;
if (parseResult.error) {
this.error = parseResult.error;
this.confidence = null;
this.ingredientParsed = null;
} else {
this.ingredientParsed = parseResult.results[0].ingredientParsed;
this.confidence = parseResult.results[0].confidence;
this.requestsRemaining = parseResult.requestsRemaining;
this.error = null;
}
Expand All @@ -66,6 +69,7 @@ export class DemoComponent implements OnInit {
reset() {
this.ingredientRaw = '';
this.ingredientParsed = null;
this.confidence = null;
this.error = null;
this.curlExample = null;
this.jsExample = null;
Expand Down
4 changes: 4 additions & 0 deletions src/app/public/docs/docs.component.html
Expand Up @@ -107,6 +107,10 @@ <h4>Fields</h4>
</li>
</ul>
</li>
<li>
<span class="code">confidence</span>: A value between 0.0 and 1.0 representing Zestful's confidence in the
result (higher is better).
</li>
<li>
<span class="code">error</span>: An error message that describes what caused
<span class="code">ingredientRaw</span>
Expand Down
5 changes: 4 additions & 1 deletion src/app/public/docs/docs.component.ts
Expand Up @@ -10,7 +10,7 @@ export class DocsComponent {
{
"ingredients": [
"3 large Granny Smith apples",
"1 1/2 cups finely chopped red onions",
"2 1/2 tablespoons finely chopped parsley",
"½ tsp brown sugar"
]
}`.substring(1);
Expand All @@ -27,6 +27,7 @@ export class DocsComponent {
"product": "Granny Smith apples",
"preparationNotes": null
},
"confidence": 0.9242,
"error": null
},
{
Expand All @@ -38,6 +39,7 @@ export class DocsComponent {
"product": "red onions",
"preparationNotes": "finely chopped"
},
"confidence": 0.5684,
"error": null
},
{
Expand All @@ -49,6 +51,7 @@ export class DocsComponent {
"product": "brown sugar",
"preparationNotes": null
},
"confidence": 0.9262,
"error": null
}
],
Expand Down

0 comments on commit e8a43cc

Please sign in to comment.