Commits

Toby Inkster committed 2961eb9

Make some triples optional.

  • Participants
  • Parent commits 9f37c20

Comments (0)

Files changed (1)

File lib/RDF/MicroTurtle/Parser.pm

 		'xsd'     => 'http://www.w3.org/2001/XMLSchema#' ,
 		};
 	
+	$RDF::Trine::Parser::parser_names{'microturtle'}       = __PACKAGE__;
 	$RDF::Trine::Parser::parser_names{'mttl'}              = __PACKAGE__;
-	$RDF::Trine::Parser::parser_names{'microturtle'}       = __PACKAGE__;
+	$RDF::Trine::Parser::parser_names{'µttl'}              = __PACKAGE__;
 	$RDF::Trine::Parser::media_types{'text/x-microturtle'} = __PACKAGE__;
 	$RDF::Trine::Parser::media_types{'text/microturtle'}   = __PACKAGE__;
 }
 
+# options:
+#   * no_agent_triples - suppresses implicit triples of the form { <@person> a foaf:Agent ; foaf:nick "person" . }
+#   * no_tag_triples - suppresses implicit triples of the form { <#hashtag> a tags:Tag ; tags:name "hashtag" . }
+#   * no_tagging_triples - suppresses implicit triples of the form { <thing> tags:taggedWithTag <#hashtag> . }
+#   * parsing_context - an instance of type RDF::MicroTurtle::Context, or a subclass.
 sub new
 {
 	my ($class, %args) = @_;
 		$handler->( $triple );
 	}
 
-	foreach my $agent (@{ $data->{agents} })
+	unless ($proto->{'no_agent_triples'})
 	{
-		foreach my $triple ($proto->{'parsing_context'}->agent_triples($agent))
+		foreach my $agent (@{ $data->{agents} })
 		{
-			$handler->( $triple );
+			foreach my $triple ($proto->{'parsing_context'}->agent_triples($agent))
+			{
+				$handler->( $triple );
+			}
 		}
 	}
 	
 	{
 		foreach my $tag (@$tags)
 		{
-			foreach my $triple ($proto->{'parsing_context'}->tagging_triples($uri, $tag))
+			unless ($proto->{'no_tagging_triples'})
 			{
-				$handler->( $triple );
+				foreach my $triple ($proto->{'parsing_context'}->tagging_triples($uri, $tag))
+				{
+					$handler->( $triple );
+				}
 			}
 			$tags_used->{$tag}++;
 		}
 	}
 	foreach my $tag (keys %$tags_used)
 	{
-		foreach my $triple ($proto->{'parsing_context'}->tag_triples($tag))
+		unless ($proto->{'no_tag_triples'})
 		{
-			$handler->( $triple );
+			foreach my $triple ($proto->{'parsing_context'}->tag_triples($tag))
+			{
+				$handler->( $triple );
+			}
 		}
 	}
 }