Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSid Jain <sija@microsoft.com>2020-10-15 12:47:21 +0300
committerSid Jain <sija@microsoft.com>2020-10-15 12:47:21 +0300
commit733418985d0a39e2c4a50963b305f247a2d20771 (patch)
tree06c953be4263de410276a4ebfe4b1071be0cf2c6
parent8837f3c2a38906521f2ea2bfaebd54634945f48f (diff)
adding test code
-rw-r--r--contrib/other-builds/MosesManagedDLL/ManagedMoses.cpp122
-rw-r--r--contrib/other-builds/MosesWrapperTest/MosesWrapperTest.csproj86
-rw-r--r--contrib/other-builds/MosesWrapperTest/Program.cs20
3 files changed, 123 insertions, 105 deletions
diff --git a/contrib/other-builds/MosesManagedDLL/ManagedMoses.cpp b/contrib/other-builds/MosesManagedDLL/ManagedMoses.cpp
index 0ba728360..da8b2393c 100644
--- a/contrib/other-builds/MosesManagedDLL/ManagedMoses.cpp
+++ b/contrib/other-builds/MosesManagedDLL/ManagedMoses.cpp
@@ -1,7 +1,3 @@
-#define NOMINMAX // Windows max macro collides with std::
-#include <Windows.h>
-#include <memory>
-#include <vcclr.h>
#include <msclr/marshal_cppstd.h>
#include "Moses2Wrapper.h"
@@ -12,105 +8,21 @@ using namespace msclr::interop;
namespace Moses {
public ref class Moses2Wrapper
{
- public:
- Moses2Wrapper(String^ filePath) {
- const std::string standardString = marshal_as<std::string>(filePath);
- m_pWrapper = new Moses2::Moses2Wrapper(standardString);
- }
- ~Moses2Wrapper() { this->!Moses2Wrapper(); }
- String^ Translate(String^ input) {
- const std::string standardString = marshal_as<std::string>(input);
- std::string output = m_pWrapper->Translate(standardString);
- //Console::WriteLine(output);
- String^ str = gcnew String(output.c_str());
- return str;
- }
-
- protected:
- !Moses2Wrapper() { delete m_pWrapper; m_pWrapper = nullptr; }
- private:
- Moses2::Moses2Wrapper *m_pWrapper;
+ public:
+ Moses2Wrapper(String^ filePath) {
+ const std::string standardString = marshal_as<std::string>(filePath);
+ m_pWrapper = new Moses2::Moses2Wrapper(standardString);
+ }
+ ~Moses2Wrapper() { this->!Moses2Wrapper(); }
+ String^ Translate(String^ input, long requestId) {
+ const std::string standardString = marshal_as<std::string>(input);
+ std::string output = m_pWrapper->Translate(standardString, requestId);
+ String^ str = gcnew String(output.c_str());
+ return str;
+ }
+ protected:
+ !Moses2Wrapper() { delete m_pWrapper; m_pWrapper = nullptr; }
+ private:
+ Moses2::Moses2Wrapper *m_pWrapper;
};
-}
-/*
-public class ManagedMoses
-{
- Moses2::Moses2Wrapper *m_Instance;
-public:
- ManagedMoses(String^ filepath) {
- const std::string standardString = marshal_as<std::string>(filepath);
- m_Instance = new Moses2::Moses2Wrapper(standardString);
-
- }
- String^ Translate(String^ input){
- const std::string standardString = marshal_as<std::string>(input);
- std::string output = m_Instance->Translate(standardString);
- //Console::WriteLine(output);
- String^ str = gcnew String(output.c_str());
- return str;
- }
-};
-
-
-/*
-#include <winsock2.h>
-#ifndef WIN32
-#define WIN32
-#endif
-#include <msclr/marshal_cppstd.h>
-#include "legacy/Parameter.h"
-#include "System.h"
-
-using namespace System;
-using namespace msclr::interop;
-
-// A wrapper around Faiss that lets you build indexes
-// Right now just proof-of-concept code to makes sure it all works from C#,
-// eventually may want to rework the interface, or possibly look at extending
-// FaissSharp to support the windows dll
-
-namespace Moses {
-
-
-
- public ref class Parameter
- {
- public:
- Parameter() { m_pWrapper = new Moses2::Parameter(); }
- ~Parameter() { this->!Parameter(); }
- bool LoadParams(String^ filePath) {
- const std::string standardString = marshal_as<std::string>(filePath);
- auto flag = m_pWrapper->LoadParam(standardString);
- return bool(flag);
- }
- Parameter* GetInstance()
- {
- return m_pWrapper;
- }
- protected:
- !Parameter() { delete m_pWrapper; m_pWrapper = nullptr; }
- private:
- Moses2::Parameter* m_pWrapper;
- };
-
-
- public ref class System {
- public:
- System(const Parameter^ paramsArg) {
- new Moses2::System(paramsArg->GetInstance());
- }
- ~System() { this->!System(); }
- protected:
- !System() { delete m_sWrapper; m_sWrapper = nullptr; }
- private:
- Moses2::System* m_sWrapper;
- Moses2::Parameter* paramArgs;
- };
-
-
-
-
-
-}
-
-*/ \ No newline at end of file
+} \ No newline at end of file
diff --git a/contrib/other-builds/MosesWrapperTest/MosesWrapperTest.csproj b/contrib/other-builds/MosesWrapperTest/MosesWrapperTest.csproj
new file mode 100644
index 000000000..333fca400
--- /dev/null
+++ b/contrib/other-builds/MosesWrapperTest/MosesWrapperTest.csproj
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{A2B603DB-F52E-4A83-BB61-F23D212E6482}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>MosesWrapperTest</RootNamespace>
+ <AssemblyName>MosesWrapperTest</AssemblyName>
+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <Deterministic>true</Deterministic>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>x64</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>2</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\MosesManagedDLL\MosesManagedDLL.vcxproj">
+ <Project>{5fb67144-27c9-4993-a084-e2097ffcc4fe}</Project>
+ <Name>MosesManagedDLL</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
+ <Visible>False</Visible>
+ <ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/contrib/other-builds/MosesWrapperTest/Program.cs b/contrib/other-builds/MosesWrapperTest/Program.cs
new file mode 100644
index 000000000..967262590
--- /dev/null
+++ b/contrib/other-builds/MosesWrapperTest/Program.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Moses;
+namespace MosesWrapperTest
+{
+ class Program {
+
+ static void Main(string[] args)
+ {
+ Moses2Wrapper e = new Moses2Wrapper("D:/moses-mstranslator/test_sentence_with_candidates/moses_mspt.ini");
+ long requestid = 123456;
+ string mystring = e.Translate("फ ो ट ो ं @@@ ट ||| a ||| 0.5338410658500136 $$$ ट ||| c ||| 0.10587171128910133 $$$ ट ||| m ||| 0.7056508746775306 $$$ ं ||| l ||| 0.29237797398236876 $$$ ं ||| o ||| 0.4026301817948226 $$$ ं ||| r ||| 0.20594041196734436 $$$ फ ||| c ||| 0.46792456587433573 $$$ फ ||| g ||| 0.43855815762641204 $$$ फ ||| x ||| 0.7077570324853759 $$$ ो ||| h ||| 0.9869239425073358 $$$ ो ||| i ||| 0.6660016809625412 $$$ ो ||| h ||| 0.8425506301302961", (int)requestid);
+ Console.WriteLine(mystring);
+ return;
+ }
+ }
+}