I am using BabelNet API 2.5 to get the synset of a word. The code for various purposes is clearly elucidated here: http://babelnet.org/guide#Mainclasses
And accordingly I write my code (In JAVA):
BabelNet bn = BabelNet.getInstance();
...
for (BabelSynset synset : bn.getSynsets(Language.EN, value, BabelPOS.NOUN,BabelSenseSource.WN))
{
System.out.println("Synset ID: " + synset.getId());
}
In the code value contains the String whose Synset I need.
But I get this error:
'The method getSynsets(Language, String, POS, BabelSenseSource...) in the type BabelNet is not applicable for the arguments (Language, String, BabelPOS, BabelSenseSource)' with the bn.getSynsets highlighted.
I am using Eclipse to do this.
Can anybody explain the error?
You must use the class POS in edu.mit.jwi.item.POS instead of BabelPOS.
import edu.mit.jwi.item.POS contained in jwi-2.1.4.jar and after you could write
bn.getSynsets(Language.EN, value, POS.NOUN, BabelSenseSource.WN)
The example code you have seen in this link is for the latest version of Babelnet (3.0), not for 2.5.
Related
To sign data, I am using signserver open-source code. I was exploring a legacy code where
it gives error at this place:
Module.getPKCS11Module().C_FindObjectsInit(session.getSessionHandle(), attributes,true);
where the Module class is from iaikpkcs11Wrapper.jar (package: iaik.pkcs.pkcs11)
As I navigate further, PKCS11 interface has this method void C_FindObjectsInit(long var1, CK_ATTRIBUTE[] var3, boolean var4) mentioned above.
Moreover, the attributes param is constructed like below:
CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTEKeyStoreContainerBase[2];
attributes[0] = new CK_ATTRIBUTE();
attributes[0].type = PKCS11Constants.CKA_CLASS;
attributes[0].pValue = new Long(PKCS11Constants.CKO_SECRET_KEY);
attributes[1] = new CK_ATTRIBUTE();
attributes[1].type = PKCS11Constants.CKA_ID;
attributes[1].pValue = id; //id is byteArray. For this param's value the error is causing
My question is, do I need to store any kind of key/certificate from where C_FindObjectsInit(..) will read or match as it says that it couldn't find any key? Where does this method search the key or how to resolve this issue?
Btw, I have read C_FindObjectsInit-JavaDoc and couldn't understand this line properly, that's why I am here:
pTemplate - the object's attribute values to match and the number of
attributes in search template (PKCS#11 param: CK_ATTRIBUTE_PTR
pTemplate, CK_ULONG ulCount)
[this may sound peculiar question, but I am really blank and stuck for few days]
PKCS#11 specification don't force us to use some strictly composed data.
But in most implementations I saw it was binary encoded OID field.
Also check for 0 (null) bytes in sequence.
I am new to Spark and GraphFrames.
When I wanted to learn about shortestPaths method in GraphFrame, GraphFrames documentation gave me a sample code in Scala, but not in Java.
In their document, they provided following (Scala code):
import org.graphframes.{examples,GraphFrame}
val g: GraphFrame = examples.Graphs.friends // get example graph
val results = g.shortestPaths.landmarks(Seq("a", "d")).run()
results.select("id", "distances").show()
and in Java, I tried:
import org.graphframes.GraphFrames;
import scala.collection.Seq;
import scala.collection.JavaConverters;
GraphFrame g = new GraphFrame(...,...);
Seq landmarkSeq = JavaConverters.collectionAsScalaIterableConverter(Arrays.asList((Object)"a",(Object)"d")).asScala().toSeq();
g.shortestPaths().landmarks(landmarkSeq).run().show();
or
g.shortestPaths().landmarks(new ArrayList<Object>(List.of((Object)"a",(Object)"d"))).run().show();
Casting to java.lang.Object was necessary since the API demands Seq<Object> or ArrayList<Object> and I could not pass ArrayList<String> to compile it right.
After running the code, I saw the message:
Exception in thread "main" org.apache.spark.sql.AnalysisException: You're using untyped Scala UDF, which does not have the input type information. Spark may blindly pass null to the Scala closure with primitive-type argument, and the closure will see the default value of the Java type for the null argument, e.g. `udf((x: Int) => x, IntegerType)`, the result is 0 for null input. To get rid of this error, you could:
1. use typed Scala UDF APIs(without return type parameter), e.g. `udf((x: Int) => x)`
2. use Java UDF APIs, e.g. `udf(new UDF1[String, Integer] { override def call(s: String): Integer = s.length() }, IntegerType)`, if input types are all non primitive
3. set spark.sql.legacy.allowUntypedScalaUDF to true and use this API with caution;
To follow the 3., I have added the code:
System.setProperty("spark.sql.legacy.allowUntypedScalaUDF","true");
but situation did not change.
Since there are limited number of sample code or stackoverflow questions about GraphFrames in Java, I could not find any useful information while seeking around.
Could anyone experienced in this area help me solve this problem?
This seems a bug in GraphFrames 0.8.0.
See Issue #367 in github.com
Following i my code in JCO3.0 to connect to RFC and get the data from function module:
try {
JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME);
JCoFunction function = destination.getRepository().getFunction("funtion_abap");
***function.getImportParameterList().setValue("IM_ID_NAME", "MTC_ZPR008_TEMPB");***
function.execute(destination);
JCoTable table = function.getTableParameterList().getTable("export_table");
}
catch(Exception e){
}
Following is my ABAP function:
CALL FUNCTION 'funtion_abap' DESTINATION m_vsyid
EXPORTING
IM_ID_NAME = table_vname
IMPORTING
export_table = table_tvarvc
EXCEPTIONS
system_failure = 1
communication_failure = 2
resource_failure = 3
OTHERS = 4.
following is an error m getting while passing String as import parameter while it wants Table field as import parameter:
Exception in thread "main" com.sap.conn.jco.ConversionException: (122) JCO_ERROR_CONVERSION: Cannot convert a value of 'MTC_ZPR008_TEMPB' from type java.lang.String to TABLE at field IM_ID_NAME
at com.sap.conn.jco.rt.AbstractRecord.createConversionException(AbstractRecord.java:468)
at com.sap.conn.jco.rt.AbstractRecord.createConversionException(AbstractRecord.java:462)
at com.sap.conn.jco.rt.AbstractRecord.setValue(AbstractRecord.java:2958)
at com.sap.conn.jco.rt.AbstractRecord.setValue(AbstractRecord.java:4074)
at com.amgen.rfc.RFC_Connection.main(RFC_Connection.java:47)
Please tell me how to solve this problem.
The RFC definition and your code are in direct opposition. According to the ABAP function (as far as I read it) the result of the call is the value in field IM_ID_NAME and the table is the input parameter.
I'm not 100% familiar with the declaration of RFCs in ABAP (I only know the Java side of it), but if I interpret the error message correctly, the table seems to be in the input parameter list rather than the table parameter list (not usual but not never seen before, either). So instead of getTableParameterList you will possible have to call getInputParameterList. Also you should omit the setting of the field IM_ID_NAME because that's the response value and resides in the output parameter list.
I know the question is quite old but someone may find my response useful one day since I had the same problem:
JcoTable tab = function.getImportParameterList().getTable("IM_ID_NAME");
tab.appendRow();
tab.firstRow(); // I'm not sure if this is actually reqiured
tab.setValue("PARAM_NAME", paramValue);
Hi i am new to groovy and i have an issue that i am facing. Currently i am trying to see the values inside typeCache[alias] which seems to be a hashtable.
protected static Hashtable typeCache = new Hashtable();
logger.error "this is type cache : " + typeCache[alias].get(indx)[1];
when i output the element i get the following result in the logs :-
this is type cache : [com.abcd.util.TypeElement#5dc97ce, com.abcd.util.TypeElement#270a8a6, com.abcd.util.TypeElement#5d421487]
am i able to expose further on the elements to see what is in them and what is it doing ?? i am used to php programming and usually in situations such as this i would do a var_dump is there an equivalent of var_dump in groovy ??
thank you.
Each object has a method, which generates a
public String dump()
Generates a detailed dump string of an object showing its class, hashCode and fields. http://docs.groovy-lang.org/latest/html/groovy-jdk/java/lang/Object.html#dump%28%29
This post contains an example, but make sure to read the comment, as the answer is not corrected as of yet.
I have seen the at (#) sign in Groovy files and I don't know if it's a Groovy or Java thing. I have tried to search on Google, Bing, and DuckDuckGo for the mystery at sign, but I haven't found anything. Can anyone please give me a resource to know more about what this operator does?
It's a Java annotation. Read more at that link.
As well as being a sign for an annotation, it's the Groovy Field operator
In Groovy, calling object.field calls the getField method (if one exists). If you actually want a direct reference to the field itself, you use #, ie:
class Test {
String name = 'tim'
String getName() {
"Name: $name"
}
}
def t = new Test()
println t.name // prints "Name: tim"
println t.#name // prints "tim"
'#' is an annotations in java/ Groovy look at the demo :Example with code
Java 5 and above supports the use of annotations to include metadata within programs. Groovy 1.1 and above also supports such annotations.
Annotations are used to provide information to tools and libraries.
They allow a declarative style of providing metadata information and allow it to be stored directly in the source code.
Such information would need to otherwise be provided using non-declarative means or using external files.
It can also be used to access attributes when parsing XML using Groovy's XmlSlurper:
def xml = '''<results><result index="1"/></results>'''
def results = new XmlSlurper().parseText(xml)
def index = results.result[0].#index.text() // prints "1"
http://groovy.codehaus.org/Reading+XML+using+Groovy's+XmlSlurper