Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] Add feature - visualization of text analaysis results and wo steps #209

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# create component failure classes from ordered steps and associate them with task executions
PREFIX cm: <http://onto.fel.cvut.cz/ontologies/csat-maintenance/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX termit: <http://onto.fel.cvut.cz/ontologies/application/termit/pojem/>
PREFIX : <http://onto.fel.cvut.cz/ontologies/csat/enhance-wo-text-0.1/>

DELETE{}
INSERT {
GRAPH cm:text-analysis-work-order-classes {
?taskExecutionIRI a ?componentFailureClass.
?componentFailureClass rdfs:subClassOf cm:component-failure--task .
}
} WHERE {
#SELECT ?taskExecutionIRI ?componentFailureClass {
{
SELECT ?taskExecutionIRI (GROUP_CONCAT(?componentFailureStep; separator=";") as ?componentFailureClassDiscrimitaor) {
{
SELECT ?taskExecutionIRI ?index ?componentFailureStep {
?taskExecutionIRI a cm:complex-execution;
rdf:type/rdfs:subClassOf cm:maintenance-work-order ;
# cm:is-part-of-workpackage ?workpackageIRI ;
cm:has-work-order-step ?taskStepExecutionIRI .

?taskStepExecutionIRI cm:described-finding ?finding .
?finding cm:has-failure-occurrence ?failureOccurrence .
?failureOccurrence termit:je-přiřazením-relace ?failureInstance.

?failureInstance :has-argument1 ?componentURI .
?failureInstance :has-argument2 ?failureURI .

FILTER (str(?componentURI) != "" && str(?failureURI) != "")

OPTIONAL{ ?taskStepExecutionIRI cm:step-index ?i . }
BIND(COALESCE(?i, "NO_INDEX") as ?index)
BIND(concat(str(?index), "-", str(?componentURI), str(?failureURI)) as ?componentFailureStep)
} ORDER BY ?taskExecutionIRI ?index
}
} GROUP BY ?taskExecutionIRI
}
BIND(IRI(concat(
"http://onto.fel.cvut.cz/ontologies/csat-maintenance/component-failure-class--",
MD5(?componentFailureClassDiscrimitaor)
)) as ?componentFailureClass
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# execution statistics of component failure classes extracted using text analysis
PREFIX cm: <http://onto.fel.cvut.cz/ontologies/csat-maintenance/>
PREFIX spif: <http://spinrdf.org/spif#>
PREFIX ofn: <http://www.ontotext.com/sparql/functions/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

DELETE{}
INSERT{
GRAPH cm:text-analysis-work-order-classes {
?componentFailureClass cm:min-work-time ?minWorkTime .
?componentFailureClass cm:max-work-time ?maxWorkTime .
?componentFailureClass cm:avg-work-time ?avgWorkTime .
?componentFailureClass cm:min-duration ?minDuration .
?componentFailureClass cm:max-duration ?maxDuration .
?componentFailureClass cm:avg-duration ?avgDuration .
}
}WHERE{
SELECT ?componentFailureClass (COUNT(*) as ?executionCount)
(MIN(?derivedWorkTime) as ?minWorkTime) (MAX(?derivedWorkTime) as ?maxWorkTime) (AVG(?derivedWorkTime) as ?avgWorkTime)
(MIN(?derivedDuration) as ?minDuration) (MAX(?derivedDuration) as ?maxDuration) (AVG(?derivedDuration) as ?avgDuration)
{

# query csat-data to get all annotated steps for a particular workpackage
{
SELECT ?taskExecutionIRI ?componentFailureClass
(MIN(?st) as ?derivedStart) (MAX(?et) as ?derivedEnd) (SUM(ofn:asMillis(?et - ?st))/1000.0/60.0/60.0 as ?derivedWorkTime) (ofn:asMillis(?derivedEnd - ?derivedStart)/1000.0/60.0/60.0 as ?derivedDuration)
{
?taskExecutionIRI a ?componentFailureClass.
?componentFailureClass rdfs:subClassOf cm:component-failure--task.

?session cm:is-part-of-maintenance-task ?taskExecutionIRI .

?session cm:start-date ?sDate.
?session cm:start-time ?sTime.
BIND(CONCAT(str(?sDate),"T", str(?sTime), IF(!contains(str(?sTime), "+"), "+02:00", "")) as ?start)

BIND(spif:parseDate(?start, "yyyy-MM-dd'T'HH:mm") as ?st)

?session cm:end-date ?eDate.
?session cm:end-time ?eTime.
BIND(CONCAT(str(?eDate),"T", str(?eTime), IF(!contains(str(?sTime), "+"), "+02:00", "")) as ?end)
BIND(spif:parseDate(?end, "yyyy-MM-dd'T'HH:mm") as ?et)

} GROUP BY ?taskExecutionIRI ?componentFailureClass
}
} GROUP BY ?componentFailureClass
}

Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,11 @@ protected String getRestrictionSubjectLabel(String restrictionSubject){
public void addTaskSteps(RevisionPlan revisionPlan, List<TaskStepPlan> steps){
steps.stream().collect(Collectors.groupingBy(s -> s.getParentTask().toString())).entrySet()
.forEach(e -> {
TaskPlan p = taskPlanMap.get(e.getKey());
p.getTaskStepPlans().addAll(e.getValue());
Optional<TaskPlan> op = Optional.ofNullable(taskPlanMap.get(e.getKey()));
op.ifPresent(
p -> p.getTaskStepPlans().addAll(e.getValue())
);

});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ WHERE
# task type
OPTIONAL{
?tt a ?tType.
?tType a cm:task-type .
OPTIONAL{
BIND(cm:task-card as ?cls)
?tt a ?cls.
Expand All @@ -57,10 +58,16 @@ WHERE
}

OPTIONAL {
?tType cm:time-estimate-in-hours ?averageTime .
?tType cm:time-estimate-in-hours ?averageTime1 .
}
}

OPTIONAL {
?tt rdf:type/cm:avg-work-time ?avgWorkTime .
}

BIND(COALESCE(?averageTime1, ?avgWorkTime) as ?averageTime)

# session
OPTIONAL{
?t cm:is-part-of-maintenance-task ?tt.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,42 @@ PREFIX ufo: <http://onto.fel.cvut.cz/ontologies/ufo/>
PREFIX csat-text: <http://onto.fel.cvut.cz/ontologies/csat/enhance-wo-text-0.1/>
PREFIX csvw: <http://www.w3.org/ns/csvw#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX termit: <http://onto.fel.cvut.cz/ontologies/application/termit/pojem/>
PREFIX : <http://onto.fel.cvut.cz/ontologies/csat/enhance-wo-text-0.1/>

SELECT ?wp ?task ?step ?stepIndex ?workOrderText ?workOrderActionText ?timeEstimateInHours ?annotatedText
SELECT ?wp ?task ?avgWorkTime ?step ?stepIndex ?workOrderText ?workOrderActionText ?timeEstimateInHours ?annotatedText
?componentUri ?componentLabel ?componentScore ?failureUri ?failureLabel ?failureScore ?aggregateScore ?isConfirmed
WHERE
{
?wp a cm:workpackage .
?task cm:is-part-of-workpackage ?wp .

# tasks
OPTIONAL{
?task cm:is-part-of-workpackage ?wp .
?task cm:has-work-order-step ?step .
?task rdf:type/rdfs:subClassOf cm:maintenance-work-order .

OPTIONAL{?step cm:step-index ?stepIndex .}
?step cm:work-order-text ?workOrderText .
OPTIONAL{?step cm:work-order-action-text ?workOrderActionText . }
# OPTIONAL{?step cm:time-estimate-in-hours ?timeEstimateInHours . }
# OPTIONAL{?task rdf:type/cm:avg-work-time ?avgWorkTime .}

?task cm:has-work-order-step ?step .
OPTIONAL{?step cm:step-index ?stepIndex .} # 148 steps are without index
?step cm:work-order-text ?workOrderText .
OPTIONAL{?step cm:work-order-action-text ?workOrderActionText . }
?step a ?stepType .
?stepType rdfs:subClassOf cm:work-order-step .

?step a ?stepType .
?stepType rdfs:subClassOf cm:work-order-step .
?step cm:described-finding ?finding.
?finding :WO_text ?annotatedText .
?finding cm:has-failure-occurrence ?failureOccurrence .
?failureOccurrence termit:má-skóre ?aggregateScore .
?failureOccurrence termit:je-přiřazením-relace ?failureInstance.

OPTIONAL{
?step a csvw:Row .
?step csat-text:AnnotatedText ?annotatedText .
OPTIONAL{
?step csat-text:FinalComponentUri ?componentUri .
OPTIONAL{?componentUri skos:prefLabel ?componentLabel .}
OPTIONAL{?step csat-text:ComponentScore ?componentScore .}
}
OPTIONAL{
?step csat-text:FinalFailureUri ?failureUri .
OPTIONAL{?failureUri skos:prefLabel ?failureLabel .}
OPTIONAL{?step csat-text:FailureScore ?failureScore .}
}
?failureInstance :has-argument1 ?componentUri.
?failureInstance :has-argument2 ?failureUri.
?componentUri skos:prefLabel ?componentLabel.
?failureUri skos:prefLabel ?failureLabel.

OPTIONAL{?step csat-text:AggregateScore ?aggregateScore .}
OPTIONAL{?step csat-text:IsConfirmed ?isConfirmed .}
}
}
# ?failureOccurrence termit:založeno-na-výskytu-termu ?componentModeOccurrence.
# ?componentModeOccurrence termit:je-přiřazením-termu ?componentUri.
# ?componentModeOccurrence termit:má-skóre ?componentScore_.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest removing irrelevant lines like this one.

# ?failureOccurrence termit:založeno-na-výskytu-termu ?failureModeOccurrence.
# ?failureModeOccurrence termit:je-přiřazením-termu ?failureUri.
# ?failureModeOccurrence termit:má-skóre ?failureScore_.
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static <T extends Resource> T generateResourceWithId(Class<T> resourcesCl
}


protected static <T extends AbstractEntity> T generateEntity(Class<T> entityClass) {
protected static <T extends AbstractEntityWithDescription> T generateEntity(Class<T> entityClass) {
try {
return entityClass.getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
Expand Down