Skip to content

Algorithm

mahamoto edited this page Jun 29, 2023 · 6 revisions

Time Trigger Logic implementation

Debugging Insights

Old Logic

      TreeGraphNode node, Collection<TypedDependency> dependencies, Action action) {
    logger.info("Check for time trigger.");
    List<TypedDependency> _toCheck =
       SearchUtils.findDependency(ListUtils.getList("tmod"), dependencies);
    for (TypedDependency td : _toCheck) {
      if (td.gov().equals(node)) {
       action.setTriggerType(TriggerType.TRIGGER_TYPE_TIME);
      }
    }
  }```

* Method CheckIsTimeTriggered checks for dependencies
* Dependencies are set in Method CreateSentence via StanfordParser
* In StanfordParser (accessed via Microservice) all dependencies are defined

* For time trigger dependency _tmod_ needs to be found
* With example sentence "Last night I swam in the pool" tmod is found 
* with example sentence "create a file on tuesday" tmod not found 
* --> tmod checking is not enough to identify time triggers correctly

_Helpfull insights_ 
* time trigger information (e.g. on tuesday) is stored in _specifier_-variable of the action object
* Class _WordNetFunctionallity_ has method _isTimePeriod_
* ! method _isTimePeriod_ doesn't recognize "am" or "pm" as periods 

_Idea_
* Not checking dependencies anymore 
* Checking the string in _specifier_ if it is a time trigger 
* Additional check for time information (am / pm) 
 
**Updated Logic**

`private static void checkIsTimeTriggered(`
          `TreeGraphNode node, Collection<TypedDependency> dependencies, Action action) {`
    `logger.info("Check for time trigger.");`
    `Boolean timeRelated = false;`
    `String specifier = action.getSpecifiers().toString();`
    `String[] words = specifier.split(" ");`
    `String word;`
    `for (int i = 0; i < words.length; i++) {`
        `word = words[i];`
        `if (WordNetWrapper.isTimePeriod(word)) {`
            `timeRelated = true;`
       `break;`
        `}`
      `if ((word.contains("pm")) || (word.contains("am"))){`
        `timeRelated = true;`
        `break;`
      `}`
    `}`
    `if (timeRelated) {`
        `action.setTriggerType(TriggerType.TRIGGER_TYPE_TIME);`
    `}`
`}`

**Further Ideas**

* Looking for more methods in _WordNetWrapper_ such as _IsTimePeriod_ to check even more eventual time information
* Combining dependency check _tmod_ with new logic to cover all eventualities 

<h1>Exporting TimeTrigger information for BPMN 2.0</h1>

**Debugging Insights**

**Further Ideas**
Clone this wiki locally