Null pointer exception on recognizer.allocate - cmusphinx

I have a doubt in sphinx4-5 prealpha release. I'm not able to use class Recognizer, earlier in sphinx4 we were able to use like this: Recognizer recognizer = new Recognizer();
recognizer.allocate();
But the same piece of code in sphinx4-5 prealpha gives me nullPointerException at recognizer.allocate();
Code Snippet:
`Configuration cn = new Configuration();
cn.setAcousticModelPath(Acoustic_Model);
cn.setDictionaryPath(Dictionary_Path);
cn.setLanguageModelPath(LANGUAGE_MODEL);
Recognizer recognizer = new Recognizer();
recognizer.allocate();`
StackTrace: Exception in thread "main" java.lang.NullPointerException at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:164) at edu.cmu.sphinx.demo.dialog.SampleSphinx.main(SampleSphinx.java:26) Exception is at recognizer.allocate
In sphinx4 we use to allocate resource from configuration like this:
Configuration configuration = new Configuration(); Recognizer recognizer = new Recognizer(); recognizer = (Recognizer) configuration.lookup();
but now as we know we use api in sphinx4-5 prealpha and we dont have lookup() in Configuration class. So how we will load JSGFGrammar and Recognizer in sphinx4-5 pre alpha. Hope I'm clear with my doubts please help in this #nikolay Thank You in advance.

Related

Settings must be of the form "name=value" in Eventhub client creation

An exception of type 'System.FormatException' occurred in Microsoft.WindowsAzure.Storage.dll but was not handled in user code
Additional information: Settings must be of the form "name=value".
while creating eventProcessorHost in EventHub
var eventProcessorHost = new EventProcessorHost(
EhEntityPath,
EventHubConsumerGroup.DefaultGroupName,
EhConnectionString,
StorageConnectionString,
StorageContainerName);
Sample values
string EhConnectionString = "Endpoint=sb://namespacename-ns.servicebus.windows.net/;SharedAccessKeyName=receivepolicy;SharedAccessKey=v7IHIH+jB3+H2UMxEOr9kHYfhwj1Q=;EntityPath=sampleeventhub";
string EhEntityPath = "sampleeventhub";
string StorageContainerName = "containername"; //I have created in blob and type as container
string StorageAccountName = "storegenameinazure";
string StorageAccountKey = "GHasmRRJgI5s123ziDlfOKQ7IBrO23EvHpk++TV0L2hU2erdI7PyY+gtvUop67lIU0+zQsM09sQ==";
static readonly string StorageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", StorageAccountName, StorageAccountKey);
According to your description, I leverage Microsoft.Azure.ServiceBus.EventProcessorHost version (2.2.10) to test this issue.
An exception of type 'System.FormatException' occurred in Microsoft.WindowsAzure.Storage.dll but was not handled in user code. Additional information: Settings must be of the form "name=value".
Based on your code, I assumed that you have not built your EventProcessorHost constructor correctly, the constructor you used looks like this:
At this point, the parameter StorageContainerName you passed would be treated as storageConnectionString parameter, then you got the above error.
In summary, please build your EventProcessorHost with the correct constructor. Here are some tutorials you could refer to them (event-processor-host-best-practices and azure-event-hubs-processing).

Create post entity to crm

I am getting unexpected error while trying to create post in Dynamics CRM. Below is the code:
Entity objEntity = new Entity("post");
objEntity["regardingobjectid"] = IncidentID;
objEntity["text"] = URLs;
objEntity["source"] = new OptionSetValue(2);
objEntity["type"] = new OptionSetValue(4);
Guid newPostID = lOrgService.Create(objEntity);
Please suggest what could be the problem.
It could be a multitude of things, which is hard to pinpoint based on the small amount of code you have submitted, but my best guess is that IncidentID is a GUID, where regardingobjectid should be an EntityReference.
Try replacing:
objEntity["regardingobjectid"] = IncidentID;
with
objEntity["regardingobjectid"] = new EntityReference("incident", IncidentID);

Error during run OrganizationRequest 'RetrieveAllEntities'

I got this error during execute, could anyone give suggestion? Thanks
OrganizationRequest oreq = new OrganizationRequest();
oreq.RequestName = "RetrieveAllEntities";// please google for available Request Names
oreq.Parameters = new ParameterCollection();
oreq.Parameters.Add(new KeyValuePair<string, object>("EntityFilters", EntityFilters.Entity));
oreq.Parameters.Add(new KeyValuePair<string, object>("RetrieveAsIfPublished", false));
OrganizationResponse respo = orgProxy.Execute(oreq);
"The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter schemas.microsoft.com/xrm/2011/Contracts/Services:ExecuteResult. The InnerException message was 'Error in line 1 position 727. Element 'schemas.datacontract.org/2004/07/System.Collections.Generic:value' contains data of the 'schemas.microsoft.com/xrm/2011/Metadata:ArrayOfEntityMetadata' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'ArrayOfEntityMetadata' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details."
Add a reference to Microsoft.Crm.Sdk.Proxy and Microsoft.Xrm.Sdk. Visual Studio may tell you that you need to add an additional couple System.* references - add them.
Use this code:
IOrganizationService service = GetCrmService(connectionString); //This is a helper, just need to setup the service
var request = new Microsoft.Xrm.Sdk.Messages.RetrieveAllEntitiesRequest()
{
EntityFilters = Microsoft.Xrm.Sdk.Metadata.EntityFilters.All,
RetrieveAsIfPublished = false
};
var response = (Microsoft.Xrm.Sdk.Messages.RetrieveAllEntitiesResponse)service.Execute(request);
Get it work finally there is two KnownTypeAttribute need to be added to the proxy class
**[System.Runtime.Serialization.KnownTypeAttribute(typeof(EntityMetadata[]))]**
public partial class OrganizationRequest : object, System.Runtime.Serialization.IExtensibleDataObject
....
**[System.Runtime.Serialization.KnownTypeAttribute(typeof(EntityMetadata[]))]**
public partial class OrganizationResponse : object, System.Runtime.Serialization.IExtensibleDataObject
Thank you for help.

I like to load my EMFText model in a standalone java applicatio

I have been looking for a possible answer but nothing yet. I found this piece of code but for Xtext
new org.eclipse.emf.mwe.utils.StandaloneSetup().setPlatformUri("../");
Injector injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
Resource resource = resourceSet.getResource(
URI.createURI("platform:/resource/org.xtext.example.mydsl/src/example.mydsl"), true);
Model model = (Model) resource.getContents().get(0);
I need to do exactly the same but using EMFText instead of Xtext. Is that possible?
I would really appreciate any help or answer.
Best regards.
Try this:
new MydslMetaInformation().registerResourceFactory();
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.getResource(URI.createFileURI("example.mydsl"), true);
Model model = (Model) resource.getContents().get(0);

unable to change the account reference inside the contact using sdk in crm2011

I am unable to change the client by updating the contact using crm 2011 sdk.Here is the code i am using to do that :
Entity contact = new Entity();
contact.LogicalName = "contact";
contact.Attributes = new AttributeCollection();
EntityReference clientLookup = new EntityReference();
clientLookup.Id = NewClientBId;
clientLookup.LogicalName = "account";
contact.Attributes.Add("parentcustomerid", clientLookup);
contact.Attributes.Add("contactid", workItem.Id);
SynchronousUtility.UpdateDynamicEntity(CrmConnector.Service, contact);
The code runs fine without any error but when i go to web portal and check the record ,it still points to the old account though updated the modofication time stamp.I also checked the sql profiler query which shows up as below :
exec sp_executesql N'update [ContactBase] set
[ModifiedOn]=#ModifiedOn0, [ModifiedBy]=#ModifiedBy0,
[ModifiedOnBehalfBy]=NULL where ([ContactId] =
#ContactId0)',N'#ModifiedOn0 datetime,#ModifiedBy0
uniqueidentifier,#ContactId0
uniqueidentifier',#ModifiedOn0='2013-07-04
09:21:02',#ModifiedBy0='2F8D969F-34AB-E111-9598-005056947387',#ContactId0='D80ACC4E-A185-E211-AB64-002324040068'
as can be seen above the column i have updated is not even there in the set clause of the update query.Can anyone help me with this ?
I tested your code and it works:
Entity contact = new Entity();
contact.LogicalName = "contact";
contact.Attributes = new AttributeCollection();
EntityReference clientLookup = new EntityReference();
clientLookup.Id = new Guid("3522bae7-5ae5-e211-9d27-b4b52f566dbc");
clientLookup.LogicalName = "account";
contact.Attributes.Add("parentcustomerid", clientLookup);
contact.Attributes.Add("contactid", new Guid("16dc4143-5ae5-e211-9d27-b4b52f566dbc"));
As you can see I used existing Id in my environment, and to perform the update I used
service.Update(contact);
Reasons why your code is not working:
NewClientBId is not the right account Guid
workItem.Id is not the right contact Guid
the function SynchronousUtility.UpdateDynamicEntity has errors

Resources