Find Jobs
Hire Freelancers

Language Parser (in PHP)(repost)

$100-500 USD

Concluído
Publicado há quase 15 anos

$100-500 USD

Pago na entrega
You are required to build a relatively simple language parser. I prefer it to be developed as a PHP class. However, if you can do it in Java (SE) bid as well. Please specify which platform you will use (PHP or Java SE). See full description for details... ## Deliverables Language Parser in PHP Platform: PHP (ideally would work on both PHP4 and PHP5) Delivered as PHP class (library). Performance is important so try to use efficient algorithms. **Language Description** Language (grammar?) elements: ~[]|\$ Given a string like the following: "alpha [bravo|charlie [delta|echo|foxtrot]|~[gulf|hotel]] india juliet ~[kilo|lima]" The program must generate variations (spins) of it. Whatever is found between brackets ("[" and "]") is a group. In such a group there can be other groups (defined by a new set of brackets) and at least one pipe character ("|") which stands for OR. So if we have "[a|b|c]" that means in a single spin only one of the three letters will be used. The program must allow for an unlimited number of groups within another group. If a group starts with "~" (e.g. "a ~[b|c]") that means the contents of the group are optional. They will either appear or not in the spin. Using the example below we could have spins like (following no particular order): "alpha bravo india juliet" - "kilo" or "lima" didn't apeared because they are optional "alpha bravo india juliet lima" - here "lima" appeared "alpha charlie echo india juliet kilo" "alpha charlie delta india juliet" "alpha gulf india juliet kilo" - used from both optional groups "alpha india juliet" - used none of the optional groups. when choosing from first group, it selected the optional "~[gulf|hotel]" but then when deciding between using it or not (because of "~") it went with the latter. Backslash character ("\") is an escape character. If it is required to have any special characters of the language as literals in the string, they will have to be preceded by "\" so they will not be interpreted. Escaping example: input: "\] alpha \[bravo\] [charlie|delta] \\" Results could be: "] alpha [bravo] charlie \" "] alpha [bravo] delta \" Dolar sign ("$[somevar]") represents a PHP variable. If the parser encounters "$[somevar]" it will look for $this->vars['somevar']. If that variable doesn't exist, is undefined, NULL or FALSE it will replace $somevar in the input string with empty string. That is, the result will contain nothinng in that place. If $this->vars['somevar'] is a number or string, it is added to the result. If it is an array, it is handled as a group, with the array values separated by pipe ("[array value 1|array value 2]"). Of course, the array values must be strings or numbers to be used otherwise they must be ignored. The value of the variable can be a spinable string, in that case being parsed the usual way. If the "$" is preceded by "~" it becomes optional as with any regular block ("an optional ~$[name] here"). Variable example: input: "[my|your] name is~$[not] [[$[name1]|$[name2]]|$[girl_names]]" $this->vars['not'] = " not"; $this->vars['name1'] = "John Doe"; $this->vars['name2'] = "Andy Smith"; $this->vars['girl_names'] = array('Anna','Jody','Mimi','[Carmen|Angelina] Jones'); Possible results: "my name is John Doe" "my name is not Mimi" "your name is not Andy Smith" "your name is Carmen Jones" "my name is not Angelina Jones" ... ** PHP Class Requirements** -------------------------------- Clear and comprehensive PHPDoc documentation for every member and method. Every algorithm used, must be documented. API: **$this->content;** // the input string **$this->vars = array();** // input variables to replace in input string **function countSpins($minVariation=0) { }** Given a $minVariation as percent (0-100), calculate how many spins can be generated having at least that variation. **function getSpin($signature) { }** Given a signature, it returns the spinned string for it. Each spin should be identified by a unique signature (possibly based on what elements from each block have been used). The signature is a sort of a hash. The signature should not require (ideally) to generate the spin in order to determine it. **function getSignature($spin) { }** Given a spin (result string), it returns its signature. **function generateSpins($minVariation) { }** Returns an array of spins having at least $minVariation as the variation. **function compareSpins($spin1, $spin2) { }** Given 2 spins (results), it returns the variation (%) between them. A 100% variation means they are completely different (unique) while 0% means they are identical. ** function validateContent($spinnableString) { }** Returns TRUE if $spinnableContent is a valid (well formatted) spinnable string. FALSE otherwise. If you can make a mechanism to determine where the error is, even better. **function displayHighlighted($spinnableString) { }** It returns a string containing the $spinnableString color coded. Basically syntax highlighter + block highlighter. It adds HTML tags with background CSS style (e.g. <span style="background:#ddddff;">[whatever goes|here]</span>) to each block and makes language entities bold (~[]|\$). ------- I am open to any suggestions. If you consider there are any limitations with my requirements or something is impossible to implement let me know. Also please specify the time it will take you to complete the project. I will set the deadline based on this. I will request to chat with you on IM, preferably voice-chat on Yahoo or Skype (if you don't have a microphone, text chat will do). Do not send me a template answer. I will reject you from start if you don't reply with a custom answer around my specific problem. Thank you
ID do Projeto: 3935278

Sobre o projeto

6 propostas
Projeto remoto
Ativo há 15 anos

Quer ganhar algum dinheiro?

Benefícios de ofertar no Freelancer

Defina seu orçamento e seu prazo
Seja pago pelo seu trabalho
Descreva sua proposta
É grátis para se inscrever e fazer ofertas em trabalhos
Concedido a:
Avatar do Usuário
See private message.
$170 USD em 34 dias
4,9 (33 avaliações)
5,3
5,3
6 freelancers estão ofertando em média $205 USD for esse trabalho
Avatar do Usuário
See private message.
$340 USD em 34 dias
5,0 (67 avaliações)
6,5
6,5
Avatar do Usuário
See private message.
$212,50 USD em 34 dias
4,9 (49 avaliações)
5,2
5,2
Avatar do Usuário
See private message.
$85 USD em 34 dias
4,7 (66 avaliações)
4,9
4,9
Avatar do Usuário
See private message.
$255 USD em 34 dias
5,0 (17 avaliações)
4,6
4,6
Avatar do Usuário
See private message.
$170 USD em 34 dias
4,6 (38 avaliações)
4,3
4,3

Sobre o cliente

Bandeira do(a) ROMANIA
Pitesti, Romania
4,7
3
Método de pagamento verificado
Membro desde mar. 22, 2002

Verificação do Cliente

Obrigado! Te enviamos um link por e-mail para que você possa reivindicar seu crédito gratuito.
Algo deu errado ao enviar seu e-mail. Por favor, tente novamente.
Usuários Registrados Total de Trabalhos Publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Carregando pré-visualização
Permissão concedida para Geolocalização.
Sua sessão expirou e você foi desconectado. Por favor, faça login novamente.