Revision: 18399 http://sourceforge.net/p/gate/code/18399 Author: ian_roberts Date: 2014-10-21 14:34:44 +0000 (Tue, 21 Oct 2014) Log Message: ----------- Make the "answer" feature name configurable when importing classification job results.
Modified Paths: -------------- gate/trunk/plugins/Crowd_Sourcing/src/gate/crowdsource/classification/EntityClassificationResultsImporter.java userguide/trunk/crowdsourcing.tex Modified: gate/trunk/plugins/Crowd_Sourcing/src/gate/crowdsource/classification/EntityClassificationResultsImporter.java =================================================================== --- gate/trunk/plugins/Crowd_Sourcing/src/gate/crowdsource/classification/EntityClassificationResultsImporter.java 2014-10-21 14:25:29 UTC (rev 18398) +++ gate/trunk/plugins/Crowd_Sourcing/src/gate/crowdsource/classification/EntityClassificationResultsImporter.java 2014-10-21 14:34:44 UTC (rev 18399) @@ -35,8 +35,9 @@ import gate.creole.metadata.RunTime; import gate.crowdsource.rest.CrowdFlowerClient; -@CreoleResource(name = "Entity Classification Results Importer", comment = "Import judgments from a CrowdFlower job created by " - + "the Entity Classification Job Builder as GATE annotations.", +@CreoleResource(name = "Entity Classification Results Importer", + comment = "Import judgments from a CrowdFlower job created by " + + "the Entity Classification Job Builder as GATE annotations.", helpURL = "http://gate.ac.uk/userguide/sec:crowd:classification:import") public class EntityClassificationResultsImporter extends @@ -59,6 +60,8 @@ private String resultASName; + private String answerFeatureName; + protected CrowdFlowerClient crowdFlowerClient; public String getApiKey() { @@ -122,6 +125,18 @@ this.resultASName = resultASName; } + public String getAnswerFeatureName() { + return answerFeatureName; + } + + @Optional + @RunTime + @CreoleParameter(defaultValue = "answer") + public void setAnswerFeatureName(String answerFeatureName) { + this.answerFeatureName = answerFeatureName; + } + + @Override public Resource init() throws ResourceInstantiationException { if(apiKey == null || "".equals(apiKey)) { @@ -160,14 +175,14 @@ for(JsonElement judgmentElt : judgments) { JsonObject judgment = judgmentElt.getAsJsonObject(); JsonObject data = judgment.getAsJsonObject("data"); - String answer = data.get("answer").getAsString(); + String answer = data.get(answerFeatureName).getAsString(); long judgmentId = judgment.get("id").getAsLong(); double trust = judgment.get("trust").getAsDouble(); long workerId = judgment.get("worker_id").getAsLong(); Annotation judgmentAnn = findOrCreate(resultAS, existingJudgments, judgmentId, entity); - judgmentAnn.getFeatures().put("answer", answer); + judgmentAnn.getFeatures().put(answerFeatureName, answer); judgmentAnn.getFeatures().put("trust", Double.valueOf(trust)); judgmentAnn.getFeatures() .put("worker_id", Long.valueOf(workerId)); Modified: userguide/trunk/crowdsourcing.tex =================================================================== --- userguide/trunk/crowdsourcing.tex 2014-10-21 14:25:29 UTC (rev 18398) +++ userguide/trunk/crowdsourcing.tex 2014-10-21 14:34:44 UTC (rev 18399) @@ -254,6 +254,8 @@ \item[resultASName/resultAnnotationType] the annotation set and type where annotations corresponding to the judgments of your annotators should be created. +\item[answerFeatureName] (default ``answer'') the name of the feature on each + result annotation that will represent the answer selected by the annotator. \item[jobId] the ID of the CrowdFlower job whose results are being imported (copy the value from the corresponding job builder PR). \end{description} @@ -269,9 +271,6 @@ \begin{description} \item[cf\_judgment] the ``judgment ID'' -- the unique identifier assigned to this judgment by CrowdFlower. -\item[answer] the answer selected by the user -- this will be one of the option - values (a map key if the options were provided as a map) or one of the common - options configured when the job was created. \item[worker\_id] the CrowdFlower identifier for the worker who provided this judgment. There is no way to track this back directly to a specific human being, but it is guaranteed that two judgments with the same worker ID were @@ -284,6 +283,11 @@ the comment field empty this feature will be omitted. \end{description} +In addition, the feature named by the \verb!answerFeatureName! parameter (by +default ``answer'') will hold the answer selected by the user -- this will be +one of the option values (a map key if the options were provided as a map) or +one of the common options configured when the job was created. + Since each generated annotation tracks the judgment ID it was created from, this PR is idempotent -- if you run it again over the same corpus then new annotations will be created for new judgments only, you will not get duplicate This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho _______________________________________________ GATE-cvs mailing list GATE-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gate-cvs