Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
실시간 편집
변경 없는 행 숨기기
줄바꿈 비활성화
레이아웃
나란히 보기
합쳐 보기
비교 단위
스마트
단어
글자
구문 강조
언어 선택
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
Untitled diff
생성일
8년 전
비교 결과 만료 없음
초기화
내보내기
공유
설명
58 삭제
행
총
삭제
글자
총
삭제
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
125 행
복사
25 추가
행
총
추가
글자
총
추가
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
93 행
복사
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
복사
복사됨
복사
복사됨
package org.apache.any23.cli;
package org.apache.any23.cli;
복사
복사됨
복사
복사됨
import org.apache.any23.cli.flows.PeopleExtractor;
import org.apache.any23.rdf.RDFUtils;
import org.apache.any23.rdf.RDFUtils;
복사
복사됨
복사
복사됨
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FileUtils;
복사
복사됨
복사
복사됨
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.model.Model;
복사
복사됨
복사
복사됨
import org.eclipse.rdf4j.model.ValueFactory;
import org.eclipse.rdf4j.model.impl.TreeModel
;
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
import org.eclipse.rdf4j.model.impl.TreeModel
Factory;
import org.eclipse.rdf4j.model.vocabulary.RDF;
import org.eclipse.rdf4j.model.vocabulary.XMLSchema;
import org.eclipse.rdf4j.rio.Rio;
import org.eclipse.rdf4j.rio.Rio;
import org.junit.Assert;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import java.io.BufferedInputStream;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileInputStream;
복사
복사됨
복사
복사됨
import java.lang.invoke.MethodHandles;
import java.util.Arrays;
import java.util.Arrays;
복사
복사됨
복사
복사됨
import java.util.
function.Function
;
import java.util.
stream.Stream
;
/**
/**
* This is example for task ANY23-396
* This is example for task ANY23-396
*
*
* @author Jacek Grzebyta (jgrzebyta@apache.org)
* @author Jacek Grzebyta (jgrzebyta@apache.org)
복사
복사됨
복사
복사됨
* @author Hans Brende (hansbrende@apache.org)
*/
*/
public class ExtractorsFlowTest extends ToolTestBase {
public class ExtractorsFlowTest extends ToolTestBase {
복사
복사됨
복사
복사됨
private static final String testingDatafile = "/org/apache/any23/extractor/csv/test-comma.csv";
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public ExtractorsFlowTest() {
public ExtractorsFlowTest() {
super(Rover.class);
super(Rover.class);
}
}
복사
복사됨
복사
복사됨
private static final String testingDatafile = "/org/apache/any23/extractor/csv/test-comma.csv";
private static final ValueFactory vf = SimpleValueFactory.getInstance();
private Logger log = LoggerFactory.getLogger(getClass());
/*
Domain ontology & data model
*/
public static final String NAMESPACE = "http://supercustom.net/ontology/";
public static final IRI PERSON = vf.createIRI(NAMESPACE, "Person");
public static final IRI FULL_NAME = vf.createIRI(NAMESPACE, "fullName");
public static final IRI HASH = vf.createIRI(NAMESPACE, "hash");
public static final String DATA_NAMESPACE = "http://rdf.supercustom.net/data/";
// domain ontology person IRI factory
public static Function<String, IRI> personIRIFactory = (String s) -> {
return vf.createIRI(DATA_NAMESPACE, DigestUtils.sha1Hex(s));
};
/**
/**
복사
복사됨
복사
복사됨
* Emulates action described in
description of issue
ANY23-396.
* Emulates action described in
ANY23-396.
* @throws Exception
*/
*/
@Test
@Test
public void runTestFor396() throws Exception {
public void runTestFor396() throws Exception {
File outputFile = File.createTempFile("mockdata-", ".ttl", tempDirectory);
File outputFile = File.createTempFile("mockdata-", ".ttl", tempDirectory);
File logFile = File.createTempFile("log-exec-", ".txt", tempDirectory);
File logFile = File.createTempFile("log-exec-", ".txt", tempDirectory);
복사
복사됨
복사
복사됨
runTool(String.format("-l %s
--workflow
-o %s -f
turtle -e csv
,people
-d %s %s",
runTool(String.format("-l %s
-o %s -f
people,
turtle -e csv
-d %s %s",
logFile.getAbsolutePath(),
logFile.getAbsolutePath(),
outputFile.getAbsolutePath(),
outputFile.getAbsolutePath(),
복사
복사됨
복사
복사됨
"urn:dataser:raw/"
,
PeopleExtractor.RAW_NS
,
copyResourceToTempFile(testingDatafile).getAbsolutePath()));
copyResourceToTempFile(testingDatafile).getAbsolutePath()));
복사
복사됨
복사
복사됨
// create some statement of expected model
Model expected = new TreeModelFactory().createEmptyModel();
String[] fullNames = new String[] {"Davide Palmisano", "Michele Mostarda", "Giovanni Tummarello"};
// populate expected model
// populate expected model
복사
복사됨
복사
복사됨
Arrays.asList(fullNames).stream().forEach( fullN -> {
Model
expected
= new TreeModel(
);
IRI person = personIRIFactory.apply(fullN);
Stream.of("Davide Palmisano", "Michele Mostarda", "Giovanni Tummarello")
expected
.add(person, RDF.TYPE, PERSON
);
.map(PeopleExtractor::createPerson).forEach(
expected
::addAll);
expected.add(person, FULL_NAME, vf.createLiteral(fullN));
expected
.add(person, HASH, vf.createLiteral(DigestUtils.sha1Hex(fullN), XMLSchema.HEXBINARY));
});
복사
복사됨
복사
복사됨
log.
info
("\n\nlog file content:\n{}", FileUtils.readFileToString(logFile, "utf-8"));
if (log.isDebugEnabled()) {
log.
info
("\n\nData file: \n{}", FileUtils.readFileToString(outputFile, "utf-8"));
log.
debug
("\n\nlog file content:\n{}", FileUtils.readFileToString(logFile, "utf-8"));
log.
debug
("\n\nData file: \n{}", FileUtils.readFileToString(outputFile, "utf-8"));
}
Assert.assertTrue(assertCompareModels(expected, outputFile));
Assert.assertTrue(assertCompareModels(expected, outputFile));
}
}
복사
복사됨
복사
복사됨
/**
/**
* Compare expected model and received from input File.
* Compare expected model and received from input File.
복사
복사됨
복사
복사됨
* @param expected
* @param received
* @return
*/
*/
복사
복사됨
복사
복사됨
public
boolean assertCompareModels(Model expected, File received) throws Exception {
private
boolean assertCompareModels(Model expected, File received) throws Exception {
Model receivedModel = new TreeModel
Factory().createEmptyModel
();
Model receivedModel = new TreeModel
();
receivedModel.addAll(Arrays.asList(RDFUtils.parseRDF(
receivedModel.addAll(Arrays.asList(RDFUtils.parseRDF(
복사
복사됨
복사
복사됨
Rio.getParserFormatForFileName(received.getName()).
get(
),
Rio.getParserFormatForFileName(received.getName()).
orElseThrow(AssertionError::new
),
new BufferedInputStream(new FileInputStream(received)),
new BufferedInputStream(new FileInputStream(received)),
received.toURI().toString()
received.toURI().toString()
)));
)));
return receivedModel.containsAll(expected);
return receivedModel.containsAll(expected);
}
}
복사
복사됨
복사
복사됨
}
}
저장된 비교 결과
원본
파일 열기
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.any23.cli; import org.apache.any23.rdf.RDFUtils; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FileUtils; import org.eclipse.rdf4j.model.IRI; import org.eclipse.rdf4j.model.Model; import org.eclipse.rdf4j.model.ValueFactory; import org.eclipse.rdf4j.model.impl.SimpleValueFactory; import org.eclipse.rdf4j.model.impl.TreeModelFactory; import org.eclipse.rdf4j.model.vocabulary.RDF; import org.eclipse.rdf4j.model.vocabulary.XMLSchema; import org.eclipse.rdf4j.rio.Rio; import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.util.Arrays; import java.util.function.Function; /** * This is example for task ANY23-396 * * @author Jacek Grzebyta (jgrzebyta@apache.org) */ public class ExtractorsFlowTest extends ToolTestBase { public ExtractorsFlowTest() { super(Rover.class); } private static final String testingDatafile = "/org/apache/any23/extractor/csv/test-comma.csv"; private static final ValueFactory vf = SimpleValueFactory.getInstance(); private Logger log = LoggerFactory.getLogger(getClass()); /* Domain ontology & data model */ public static final String NAMESPACE = "http://supercustom.net/ontology/"; public static final IRI PERSON = vf.createIRI(NAMESPACE, "Person"); public static final IRI FULL_NAME = vf.createIRI(NAMESPACE, "fullName"); public static final IRI HASH = vf.createIRI(NAMESPACE, "hash"); public static final String DATA_NAMESPACE = "http://rdf.supercustom.net/data/"; // domain ontology person IRI factory public static Function<String, IRI> personIRIFactory = (String s) -> { return vf.createIRI(DATA_NAMESPACE, DigestUtils.sha1Hex(s)); }; /** * Emulates action described in description of issue ANY23-396. * @throws Exception */ @Test public void runTestFor396() throws Exception { File outputFile = File.createTempFile("mockdata-", ".ttl", tempDirectory); File logFile = File.createTempFile("log-exec-", ".txt", tempDirectory); runTool(String.format("-l %s --workflow -o %s -f turtle -e csv,people -d %s %s", logFile.getAbsolutePath(), outputFile.getAbsolutePath(), "urn:dataser:raw/", copyResourceToTempFile(testingDatafile).getAbsolutePath())); // create some statement of expected model Model expected = new TreeModelFactory().createEmptyModel(); String[] fullNames = new String[] {"Davide Palmisano", "Michele Mostarda", "Giovanni Tummarello"}; // populate expected model Arrays.asList(fullNames).stream().forEach( fullN -> { IRI person = personIRIFactory.apply(fullN); expected.add(person, RDF.TYPE, PERSON); expected.add(person, FULL_NAME, vf.createLiteral(fullN)); expected.add(person, HASH, vf.createLiteral(DigestUtils.sha1Hex(fullN), XMLSchema.HEXBINARY)); }); log.info("\n\nlog file content:\n{}", FileUtils.readFileToString(logFile, "utf-8")); log.info("\n\nData file: \n{}", FileUtils.readFileToString(outputFile, "utf-8")); Assert.assertTrue(assertCompareModels(expected, outputFile)); } /** * Compare expected model and received from input File. * @param expected * @param received * @return */ public boolean assertCompareModels(Model expected, File received) throws Exception { Model receivedModel = new TreeModelFactory().createEmptyModel(); receivedModel.addAll(Arrays.asList(RDFUtils.parseRDF( Rio.getParserFormatForFileName(received.getName()).get(), new BufferedInputStream(new FileInputStream(received)), received.toURI().toString() ))); return receivedModel.containsAll(expected); } }
수정본
파일 열기
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.any23.cli; import org.apache.any23.cli.flows.PeopleExtractor; import org.apache.any23.rdf.RDFUtils; import org.apache.commons.io.FileUtils; import org.eclipse.rdf4j.model.Model; import org.eclipse.rdf4j.model.impl.TreeModel; import org.eclipse.rdf4j.rio.Rio; import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.lang.invoke.MethodHandles; import java.util.Arrays; import java.util.stream.Stream; /** * This is example for task ANY23-396 * * @author Jacek Grzebyta (jgrzebyta@apache.org) * @author Hans Brende (hansbrende@apache.org) */ public class ExtractorsFlowTest extends ToolTestBase { private static final String testingDatafile = "/org/apache/any23/extractor/csv/test-comma.csv"; private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); public ExtractorsFlowTest() { super(Rover.class); } /** * Emulates action described in ANY23-396. */ @Test public void runTestFor396() throws Exception { File outputFile = File.createTempFile("mockdata-", ".ttl", tempDirectory); File logFile = File.createTempFile("log-exec-", ".txt", tempDirectory); runTool(String.format("-l %s -o %s -f people,turtle -e csv -d %s %s", logFile.getAbsolutePath(), outputFile.getAbsolutePath(), PeopleExtractor.RAW_NS, copyResourceToTempFile(testingDatafile).getAbsolutePath())); // populate expected model Model expected = new TreeModel(); Stream.of("Davide Palmisano", "Michele Mostarda", "Giovanni Tummarello") .map(PeopleExtractor::createPerson).forEach(expected::addAll); if (log.isDebugEnabled()) { log.debug("\n\nlog file content:\n{}", FileUtils.readFileToString(logFile, "utf-8")); log.debug("\n\nData file: \n{}", FileUtils.readFileToString(outputFile, "utf-8")); } Assert.assertTrue(assertCompareModels(expected, outputFile)); } /** * Compare expected model and received from input File. */ private boolean assertCompareModels(Model expected, File received) throws Exception { Model receivedModel = new TreeModel(); receivedModel.addAll(Arrays.asList(RDFUtils.parseRDF( Rio.getParserFormatForFileName(received.getName()).orElseThrow(AssertionError::new), new BufferedInputStream(new FileInputStream(received)), received.toURI().toString() ))); return receivedModel.containsAll(expected); } }
비교하기