Skip to content

Commit

Permalink
Deal with invalid UTF-8 encodings
Browse files Browse the repository at this point in the history
  • Loading branch information
CoralineAda committed Sep 18, 2017
1 parent 87ea7cb commit c7dcea9
Show file tree
Hide file tree
Showing 36 changed files with 402 additions and 1 deletion.
1 change: 1 addition & 0 deletions alice/parser/google.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def all_answers

def results
answers = full_search + reductivist_search
answers.map!{|a| a.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')}
answers.reject!{|a| a.include?("...")}
sorted_answers = answers.sort{|a,b| declarative_index(a) <=> declarative_index(b)}
best_answer = sorted_answers.any? && sorted_answers.first.split.join(' ') || ""
Expand Down
2 changes: 1 addition & 1 deletion alice/parser/wikipedia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def answer

def results
if result = ::Wikipedia.find(topic)
content = Grammar::LanguageHelper.sentences_from(result.sanitized_content)
content = Grammar::LanguageHelper.sentences_from(result.sanitized_content.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: ''))
else
content = []
end
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
400 changes: 400 additions & 0 deletions db/neo4j/development/logs/debug.log

Large diffs are not rendered by default.

0 comments on commit c7dcea9

Please sign in to comment.