Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
Untitled diff
Créé
il y a 7 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
35 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
60 lignes
Copier tout
25 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
52 lignes
Copier tout
Copier
Copié
Copier
Copié
const
algorithmia
= require(
'algorithmia'
)
import
algorithmia
from
'algorithmia'
;
const algorithmiaApiKey = require('../credentials/algorithmia.json').apiKey
const algorithmiaApiKey = require('../credentials/algorithmia.json').apiKey
Copier
Copié
Copier
Copié
const
sentenceBoundaryDetection
= require(
'sbd'
)
import
sentenceBoundaryDetection
from
'sbd'
;
import { IContent } from './robots.api';
Copier
Copié
Copier
Copié
async function robot(content
) {
async function robot(content
: IContent
) {
await fetchContentFromWikipedia(content)
await fetchContentFromWikipedia(content)
sanitizeContent(content)
sanitizeContent(content)
breakContentIntoSentences(content)
breakContentIntoSentences(content)
Copier
Copié
Copier
Copié
async function fetchContentFromWikipedia(content
) {
async function fetchContentFromWikipedia(content
: IContent
) {
const algorithmiaAuthenticated = algorithmia(algorithmiaApiKey)
const algorithmiaAuthenticated = algorithmia(algorithmiaApiKey)
const wikipediaAlgorithm = algorithmiaAuthenticated.algo('web/WikipediaParser/0.1.2')
const wikipediaAlgorithm = algorithmiaAuthenticated.algo('web/WikipediaParser/0.1.2')
const wikipediaResponde = await wikipediaAlgorithm.pipe(content.searchTerm)
const wikipediaResponde = await wikipediaAlgorithm.pipe(content.searchTerm)
Copier
Copié
Copier
Copié
const
wikipediaContent
= wikipediaResponde.get()
const
{
wikipediaContent
}
= wikipediaResponde.get()
content.sourceContentOriginal = wikipediaContent
.content
content.sourceContentOriginal = wikipediaContent
}
}
Copier
Copié
Copier
Copié
function sanitizeContent(content
) {
function sanitizeContent(content
: IContent
) {
const withoutBlankLinesAndMarkdown = removeBlankLinesAndMarkdown(content.sourceContentOriginal)
const withoutBlankLinesAndMarkdown = removeBlankLinesAndMarkdown(content.sourceContentOriginal)
const withoutDatesInParentheses = removeDatesInParentheses(withoutBlankLinesAndMarkdown)
const withoutDatesInParentheses = removeDatesInParentheses(withoutBlankLinesAndMarkdown)
content.sourceContentSanitized = withoutDatesInParentheses
content.sourceContentSanitized = withoutDatesInParentheses
Copier
Copié
Copier
Copié
function removeBlankLinesAndMarkdown(text
)
{
function removeBlankLinesAndMarkdown(text
: string): string
{
const allLines = text.split('\n')
const allLines = text.split('\n')
Copier
Copié
Copier
Copié
const
withoutBlankLinesAndMarkdown = allLines.
filter
(
(line
) =>
{
const
filter
Func =
(line
: string
) =>
if
(line.trim().length === 0 || line.trim().startsWith('='))
{
!
(line.trim().length === 0 || line.trim().startsWith('='))
return false
}
return
allLines.filter(filterFunc)
.join(' ')
return true
})
return
withoutBlankLinesAndMarkdown
.join(' ')
}
}
}
}
Copier
Copié
Copier
Copié
function removeDatesInParentheses(text
)
{
function removeDatesInParentheses(text
: string): string
{
return text.replace(/\((?:\([^()]*\)|[^()])*\)/gm, '').replace(/ /g,' ')
return text.replace(/\((?:\([^()]*\)|[^()])*\)/gm, '').replace(/ /g,' ')
}
}
Copier
Copié
Copier
Copié
function breakContentIntoSentences(content
) {
function breakContentIntoSentences(content
: IC
ontent
) {
c
ontent
.sentences = []
const sentences = sentenceBoundaryDetection.sentences(content.sourceContentSanitized)
const sentences = sentenceBoundaryDetection.sentences(content.sourceContentSanitized)
Copier
Copié
Copier
Copié
sentences.forEach((sentence) => {
content.sentences = sentences.map((text: string) => ({
content.sentences.push({
text,
text: sentence,
keywords: [],
keywords: [],
images: []
images: []
})
)
})
}
)
}
}
}
}
module.exports = robot
module.exports = robot
Différences enregistrées
Texte d'origine
Ouvrir un fichier
const algorithmia = require('algorithmia') const algorithmiaApiKey = require('../credentials/algorithmia.json').apiKey const sentenceBoundaryDetection = require('sbd') async function robot(content) { await fetchContentFromWikipedia(content) sanitizeContent(content) breakContentIntoSentences(content) async function fetchContentFromWikipedia(content) { const algorithmiaAuthenticated = algorithmia(algorithmiaApiKey) const wikipediaAlgorithm = algorithmiaAuthenticated.algo('web/WikipediaParser/0.1.2') const wikipediaResponde = await wikipediaAlgorithm.pipe(content.searchTerm) const wikipediaContent = wikipediaResponde.get() content.sourceContentOriginal = wikipediaContent.content } function sanitizeContent(content) { const withoutBlankLinesAndMarkdown = removeBlankLinesAndMarkdown(content.sourceContentOriginal) const withoutDatesInParentheses = removeDatesInParentheses(withoutBlankLinesAndMarkdown) content.sourceContentSanitized = withoutDatesInParentheses function removeBlankLinesAndMarkdown(text) { const allLines = text.split('\n') const withoutBlankLinesAndMarkdown = allLines.filter((line) => { if (line.trim().length === 0 || line.trim().startsWith('=')) { return false } return true }) return withoutBlankLinesAndMarkdown.join(' ') } } function removeDatesInParentheses(text) { return text.replace(/\((?:\([^()]*\)|[^()])*\)/gm, '').replace(/ /g,' ') } function breakContentIntoSentences(content) { content.sentences = [] const sentences = sentenceBoundaryDetection.sentences(content.sourceContentSanitized) sentences.forEach((sentence) => { content.sentences.push({ text: sentence, keywords: [], images: [] }) }) } } module.exports = robot
Texte modifié
Ouvrir un fichier
import algorithmia from 'algorithmia'; const algorithmiaApiKey = require('../credentials/algorithmia.json').apiKey import sentenceBoundaryDetection from 'sbd'; import { IContent } from './robots.api'; async function robot(content: IContent) { await fetchContentFromWikipedia(content) sanitizeContent(content) breakContentIntoSentences(content) async function fetchContentFromWikipedia(content: IContent) { const algorithmiaAuthenticated = algorithmia(algorithmiaApiKey) const wikipediaAlgorithm = algorithmiaAuthenticated.algo('web/WikipediaParser/0.1.2') const wikipediaResponde = await wikipediaAlgorithm.pipe(content.searchTerm) const { wikipediaContent } = wikipediaResponde.get() content.sourceContentOriginal = wikipediaContent } function sanitizeContent(content: IContent) { const withoutBlankLinesAndMarkdown = removeBlankLinesAndMarkdown(content.sourceContentOriginal) const withoutDatesInParentheses = removeDatesInParentheses(withoutBlankLinesAndMarkdown) content.sourceContentSanitized = withoutDatesInParentheses function removeBlankLinesAndMarkdown(text: string): string { const allLines = text.split('\n') const filterFunc = (line: string) => !(line.trim().length === 0 || line.trim().startsWith('=')) return allLines.filter(filterFunc).join(' ') } } function removeDatesInParentheses(text: string): string { return text.replace(/\((?:\([^()]*\)|[^()])*\)/gm, '').replace(/ /g,' ') } function breakContentIntoSentences(content: IContent) { const sentences = sentenceBoundaryDetection.sentences(content.sourceContentSanitized) content.sentences = sentences.map((text: string) => ({ text, keywords: [], images: [] })) } } module.exports = robot
Trouver la différence