Skip to content
This repository has been archived by the owner on Mar 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #143 from AmyAssist/NLandAGFparser
Browse files Browse the repository at this point in the history
NL and AGF handling
  • Loading branch information
FlxB2 authored Jul 17, 2018
2 parents bdf5014 + 27e0a23 commit 52e2d55
Show file tree
Hide file tree
Showing 72 changed files with 3,765 additions and 1,237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* For more information see notice.md
*/

package de.unistuttgart.iaas.amyassist.amy.core.plugin.api;
package de.unistuttgart.iaas.amyassist.amy.core.natlang.api;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
Expand All @@ -38,7 +38,12 @@
@Target(java.lang.annotation.ElementType.METHOD)
public @interface Grammar {
/**
* @return the grammar
* The string inside this annotation has to be in
* Amy Grammar Format (AGF), a description and examples
* can be found in the amy-assist wiki
* https://github.com/AmyAssist/Amy/wiki/Annotations
*
* @return the grammar in AGF - Amy Grammar Format
*/
String value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* For more information see notice.md
*/

package de.unistuttgart.iaas.amyassist.amy.core.plugin.api;
package de.unistuttgart.iaas.amyassist.amy.core.natlang.api;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
Expand All @@ -37,8 +37,5 @@
@Documented
@Target(java.lang.annotation.ElementType.TYPE)
public @interface SpeechCommand {
/**
* @return the keyword of the speech command
*/
String[] value();

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,4 @@
*/
public interface SpeechIO extends Runnable {

/**
* Setter for the SpeechInputHandler. The SpeechInputHandler is used to process the user input.
*
* @param handler
* the SpeechInputHandler to use
*/
void setSpeechInputHandler(SpeechInputHandler handler);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

import de.unistuttgart.iaas.amyassist.amy.registry.rest.ContactRegistryResource;
import de.unistuttgart.iaas.amyassist.amy.registry.rest.LocationRegistryResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -41,11 +39,12 @@
import de.unistuttgart.iaas.amyassist.amy.core.pluginloader.PluginManager;
import de.unistuttgart.iaas.amyassist.amy.core.pluginloader.PluginProvider;
import de.unistuttgart.iaas.amyassist.amy.core.speech.LocalAudioUserInteraction;
import de.unistuttgart.iaas.amyassist.amy.core.speech.SpeechInputHandler;
import de.unistuttgart.iaas.amyassist.amy.core.speech.result.handler.SpeechCommandHandler;
import de.unistuttgart.iaas.amyassist.amy.core.speech.grammar.GrammarObjectsCreator;
import de.unistuttgart.iaas.amyassist.amy.core.taskscheduler.TaskScheduler;
import de.unistuttgart.iaas.amyassist.amy.core.taskscheduler.api.TaskSchedulerAPI;
import de.unistuttgart.iaas.amyassist.amy.httpserver.Server;
import de.unistuttgart.iaas.amyassist.amy.registry.rest.ContactRegistryResource;
import de.unistuttgart.iaas.amyassist.amy.registry.rest.LocationRegistryResource;
import de.unistuttgart.iaas.amyassist.amy.restresources.home.HomeResource;

/**
Expand Down Expand Up @@ -114,7 +113,6 @@ private void init() {
ConfigurationLoader configLoader = this.di.getService(ConfigurationLoader.class);
this.config = configLoader.load(CONFIG_NAME);

SpeechCommandHandler speechCommandHandler = this.di.getService(SpeechCommandHandler.class);
this.threads = new ArrayList<>();

this.server = this.di.getService(Server.class);
Expand All @@ -124,13 +122,12 @@ private void init() {

initConsole();

this.recognizer = this.di.getService(LocalAudioUserInteraction.class);

PluginManager pluginManager = this.di.getService(PluginManager.class);
pluginManager.loadPlugins();
this.di.registerContextProvider(Context.PLUGIN, new PluginProvider(pluginManager.getPlugins()));
speechCommandHandler.completeSetup();

this.di.getService(GrammarObjectsCreator.class).completeSetup();
this.recognizer = this.di.getService(LocalAudioUserInteraction.class);
this.recognizer.init();
}

Expand All @@ -142,7 +139,6 @@ private void initConsole() {
}
if (enableConsole.equals("true")) {
Console console = this.di.getService(Console.class);
console.setSpeechInputHandler(this.di.getService(SpeechInputHandler.class));
this.threads.add(new Thread(console));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

import java.util.Properties;

import de.unistuttgart.iaas.amyassist.amy.registry.ContactRegistryImpl;
import de.unistuttgart.iaas.amyassist.amy.registry.LocationRegistryImpl;
import org.slf4j.Logger;

import de.unistuttgart.iaas.amyassist.amy.core.configuration.ConfigurationLoaderImpl;
Expand All @@ -36,15 +34,17 @@
import de.unistuttgart.iaas.amyassist.amy.core.di.ServiceProviderLoader;
import de.unistuttgart.iaas.amyassist.amy.core.io.EnvironmentService;
import de.unistuttgart.iaas.amyassist.amy.core.logger.LoggerProvider;
import de.unistuttgart.iaas.amyassist.amy.core.natlang.NLProcessingManagerImpl;
import de.unistuttgart.iaas.amyassist.amy.core.persistence.PersistenceService;
import de.unistuttgart.iaas.amyassist.amy.core.persistence.storage.DatabaseStorage;
import de.unistuttgart.iaas.amyassist.amy.core.pluginloader.PluginLoader;
import de.unistuttgart.iaas.amyassist.amy.core.pluginloader.PluginManagerService;
import de.unistuttgart.iaas.amyassist.amy.core.speech.LocalAudioUserInteraction;
import de.unistuttgart.iaas.amyassist.amy.core.speech.grammar.GrammarObjectsCreator;
import de.unistuttgart.iaas.amyassist.amy.core.speech.result.handler.SpeechCommandHandler;
import de.unistuttgart.iaas.amyassist.amy.core.speech.tts.TextToSpeech;
import de.unistuttgart.iaas.amyassist.amy.httpserver.Server;
import de.unistuttgart.iaas.amyassist.amy.registry.ContactRegistryImpl;
import de.unistuttgart.iaas.amyassist.amy.registry.LocationRegistryImpl;

/**
* Register the Services of Core
Expand All @@ -63,7 +63,7 @@ public void load(Configuration di) {
di.register(Server.class);
di.register(ConfigurationImpl.class);
di.register(Console.class);
di.register(SpeechCommandHandler.class);
di.register(NLProcessingManagerImpl.class);
di.register(ConfigurationLoaderImpl.class);
di.register(PluginLoader.class);
di.register(PluginManagerService.class);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
import de.unistuttgart.iaas.amyassist.amy.core.di.annotation.PostConstruct;
import de.unistuttgart.iaas.amyassist.amy.core.di.annotation.Reference;
import de.unistuttgart.iaas.amyassist.amy.core.di.annotation.Service;
import de.unistuttgart.iaas.amyassist.amy.core.natlang.LanguageSpecifics;
import de.unistuttgart.iaas.amyassist.amy.core.natlang.NLProcessingManager;
import de.unistuttgart.iaas.amyassist.amy.core.speech.SpeechInputHandler;
import de.unistuttgart.iaas.amyassist.amy.core.speech.result.handler.SpeechCommandHandler;

/**
* Implementation of SpeechInputHandler
Expand All @@ -43,21 +44,24 @@ public class NaturalLanaguageInputHandlerService implements SpeechInputHandler {
private Core core;

@Reference
private SpeechCommandHandler speechCommandHandler;
private NLProcessingManager nlProcessingManager;

private ScheduledExecutorService singleThreadScheduledExecutor;

private LanguageSpecifics lang;

@PostConstruct
private void setup() {
this.singleThreadScheduledExecutor = this.core.getScheduledExecutor();
this.lang = new LanguageSpecifics();
}

/**
* @see de.unistuttgart.iaas.amyassist.amy.core.speech.SpeechInputHandler#handle(java.lang.String)
*/
@Override
public CompletableFuture<String> handle(String speechInput) {
return CompletableFuture.supplyAsync(() -> this.speechCommandHandler.handleSpeechInput(speechInput),
public CompletableFuture<String> handle(String naturalLanguageText) {
return CompletableFuture.supplyAsync(() -> this.nlProcessingManager.process(naturalLanguageText, this.lang),
this.singleThreadScheduledExecutor);
}

Expand Down
Loading

0 comments on commit 52e2d55

Please sign in to comment.