Skip to content

Commit

Permalink
Merge pull request #1323 from botpress/f_nlu-fix-strip-chars
Browse files Browse the repository at this point in the history
fix(NLU): various fixes => see desc
  • Loading branch information
EFF committed Jan 17, 2019
2 parents cb8bb84 + b794031 commit db04ed8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
2 changes: 1 addition & 1 deletion modules/nlu/src/backend/pipelines/intents/ft_classifier.ts
Expand Up @@ -17,7 +17,7 @@ export default class FastTextClassifier implements IntentClassifier {
private fastTextWrapper!: FastTextWrapper

private sanitizeText(text: string): string {
return text.toLowerCase().replace(/[^\w\s]/gi, '')
return text.toLowerCase().replace(/[^\w\s]|\r|\f/gi, '')
}

private _writeTrainingSet(intents: TrainSet[], trainingFilePath: string) {
Expand Down
15 changes: 9 additions & 6 deletions modules/nlu/src/views/intents/draft/editor.jsx
Expand Up @@ -369,26 +369,29 @@ export default class IntentEditor extends React.Component {
})

return (
<div className={className} tabIndex={0} onBlur={onBlur} onFocus={onFocus}>
<div className={className}>
<div className={style.editor}>
<Editor
tabIndex={this.props.tabIndex}
handleBeforeInput={this.handleBeforeInput}
handleKeyCommand={this.handleKeyCommand}
keyBindingFn={myKeyBindingFn}
editorState={this.state.editorState}
onChange={this.onChange}
placeholder="Type to create a new utterance"
onBlur={this.onBlur}
onBlur={onBlur}
onFocus={onFocus}
ref={el => (this.domRef = el)}
onUpArrow={this.onArrow('moveUp')}
onDownArrow={this.onArrow('moveDown')}
onTab={this.onArrow('moveDown')}
/>
</div>
<div className={style.controls}>
<span className={style.action} onClick={this.props.deleteUtterance}>
Remove Utterance
</span>
{
this.state.editorState.getCurrentContent().hasText() && (
<span className={`${style.action} glyphicon glyphicon-trash`} onClick={this.props.deleteUtterance}></span>
)
}
</div>
</div>
)
Expand Down
43 changes: 23 additions & 20 deletions modules/nlu/src/views/intents/draft/style.scss
@@ -1,41 +1,44 @@
.editorContainer {
width: 100%;
display: flex;
padding: 10px;

.controls {
display: none;
margin-top: 5px;
text-align: right;
display: block;
width: 5%;
text-align: center;
}

.action {
text-decoration: underline;
cursor: pointer;
margin-top: 7px;
display: none;
}

&.focus {
background-color: #fff889;
background-color: #eee;
outline: none;
}

.controls {
&:hover {
.action {
display: block;
}
}
}

.editor {
background-color: white;
width: 100%;
border: 1px solid #ececec;
font-size: 16px;
padding: 5px;
display: block;
.editor {
background-color: white;
width: 95%;
border: 1px solid #ececec;
font-size: 16px;
padding: 5px;
display: block;

&:hover {
border: 1px solid #cbcbcb;
&:hover {
border: 1px solid #cbcbcb;
}
}
}

.entity-label {
cursor: pointer;
.entity-label {
cursor: pointer;
}
}
1 change: 1 addition & 0 deletions modules/nlu/src/views/intents/editor.jsx
Expand Up @@ -135,6 +135,7 @@ export default class IntentsEditor extends React.Component {
return (
<li key={`uttr-${utterance.id}`}>
<Editor
tabIndex={i + 1}
getSlotsEditor={() => this.slotsEditor}
ref={el => {
if (i === 0) {
Expand Down

0 comments on commit db04ed8

Please sign in to comment.