This is an automated email from the ASF dual-hosted git repository. aradzinski pushed a commit to branch NLPCRAFT-474 in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-474 by this push: new dd84682 WIP dd84682 is described below commit dd84682a3b00b5306cf5d18cce1a15572213c5b9 Author: Aaron Radzinski <aradzin...@datalingvo.com> AuthorDate: Fri Jan 21 11:01:45 2022 -0800 WIP --- .../nlpcraft/internal/intent/NCIDLContext.scala | 41 +++++++++++++++++ .../nlpcraft/internal/intent/NCIDLFunction.scala | 25 +++++++++++ .../nlpcraft/internal/intent/NCIDLStack.scala | 52 ++++++++++++++++++++++ .../intent/compiler/NCIntentCompiler.scala | 27 +++++++++++ .../internal/intent/matcher/NCIntentMatcher.scala | 27 +++++++++++ 5 files changed, 172 insertions(+) diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/NCIDLContext.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/NCIDLContext.scala new file mode 100644 index 0000000..87d0c68 --- /dev/null +++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/NCIDLContext.scala @@ -0,0 +1,41 @@ +/* + * 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 + * + * https://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.nlpcraft.internal.intent + +import org.apache.nlpcraft.* + +import scala.collection.mutable + +/** + * + * @param toks User input tokens. + * @param intentMeta Intent metadata. + * @param convMeta Conversation metadata. + * @param fragMeta Fragment (argument) metadata passed during intent fragment reference. + * @param req Server request holder. + * @param vars Intent variable storage. + */ +case class NCIDLContext( + toks: Seq[NCEntity] = Seq.empty, + intentMeta: Map[String, Object] = Map.empty, + convMeta: Map[String, Object] = Map.empty, + fragMeta: Map[String, Object] = Map.empty, + req: NCRequest, + vars: mutable.Map[String, NCIDLFunction] = mutable.HashMap.empty +) + diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/NCIDLFunction.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/NCIDLFunction.scala new file mode 100644 index 0000000..a094024 --- /dev/null +++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/NCIDLFunction.scala @@ -0,0 +1,25 @@ +/* + * 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 + * + * https://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.nlpcraft.internal.intent + +import org.apache.nlpcraft.* + +/** + * + */ +trait NCIDLFunction extends ((NCEntity, NCIDLContext) => NCIDLStackItem) diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/NCIDLStack.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/NCIDLStack.scala new file mode 100644 index 0000000..c36c683 --- /dev/null +++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/NCIDLStack.scala @@ -0,0 +1,52 @@ +/* + * 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 + * + * https://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.nlpcraft.internal.intent + +import scala.collection.mutable + +/** + * + */ +case class NCIDLStackItem ( + value: Object, + entUse: Int +) + +/** + * + */ +object NCIDLStackItem { + def apply(v: Boolean, f: Int): NCIDLStackItem = new NCIDLStackItem(Boolean.box(v), f) + def apply(v: Long, f: Int): NCIDLStackItem = new NCIDLStackItem(Long.box(v), f) + def apply(v: Double, f: Int): NCIDLStackItem = new NCIDLStackItem(Double.box(v), f) +} + +/** + * + */ +trait NCIDLStackType extends (() => NCIDLStackItem) + +/** + * + */ +class NCIDLStack extends mutable.Stack[NCIDLStackType]: + /** + * Special marker for stack frames. + */ + final val PLIST_MARKER: NCIDLStackType = () => { NCIDLStackItem(null, 0) } + diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIntentCompiler.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIntentCompiler.scala new file mode 100644 index 0000000..2875001 --- /dev/null +++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIntentCompiler.scala @@ -0,0 +1,27 @@ +/* + * 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 + * + * https://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.nlpcraft.internal.intent.compiler + +/** + * + */ +object NCIntentCompiler: + /** + * + */ + def compile(): Unit = ??? diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/matcher/NCIntentMatcher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/matcher/NCIntentMatcher.scala new file mode 100644 index 0000000..5fde322 --- /dev/null +++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/matcher/NCIntentMatcher.scala @@ -0,0 +1,27 @@ +/* + * 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 + * + * https://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.nlpcraft.internal.intent.matcher + +/** + * + */ +object NCIntentMatcher: + /** + * + */ + def bestMatch(): Unit = ??? \ No newline at end of file