Converting C to PHP? [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Is there any tool available that takes C code as input and outputs valid PHP files?
I'd like to use the SAC API but all the implementations currently available are in C, Java, Ruby and Perl. I wonder if the C implementation can be converted to PHP easily.

I've never seen any tool to do that ; but the way that's generally used when one wants to use some C library from PHP is to write a PHP extension, that acts as some kind of "bridge" between the PHP userland-code, and the C library.
That's how you are able to use the curl library from PHP, for example.
A couple of interesting reads on that matter :
Extension Writing Part I: Introduction to PHP and Zend
Extension Writing Part II: Parameters, Arrays, and ZVALs
Extension Writing Part II: Parameters, Arrays, and ZVALs [continued]
Extension Writing Part III: Resources
Wrapping C++ Classes in a PHP Extension
And, if you are really interested by the subject, and ready to spend some money on it, you could also buy the book Extending and Embedding PHP (some pages are available as preview on Google Books too) ; I've seen a couple of times that it was the book to read when interested on this subject (In fact, I've bought it some time ago, and it's an interesting read, even if you don't plan on writing an extension right now)
BTW, the author of that book is also the author of the first four articles I linked to ;-)

The answer is The simplified wrapper and interface generator
It's a huge library and tool and has a steep learning curve so maybe you should ask yourself if the API you want to wrap is really complicated enough to use SWIG or if it's not faster to do it manually.

Related

Is there a lemmatizer for PHP? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
Does anyone know of a lemmatizer in PHP? Or, at worst, some way to use a lemmatizer in another language (python NLTK, for instance?) in a PHP webapp?
I'm building a macro-etymological analyzer and I've encountered this issue where the etymological database doesn't contain conjugated words. A lemmatizer would correct this, I think, by giving me the word "say" when the dictionary can't find "said," and returning "good" when the dictionary can't find "better," etc.
Note: a stemmer wouldn't do the same thing as a lemmatizer.
Does this help?
http://tartarus.org/~martin/PorterStemmer/php.txt
It's a PHP5 implementation of the Porter Stemmer algorithm.
i googled this:
http://pastebin.com/WNvb2zB4
and this.
http://tartarus.org/~martin/PorterStemmer/php.txt
dunno if any of them works.
Isn't a https://github.com/heromantor/phpmorphy is what you looking for?
Lemmatisation is relatively more complicated as compare to stemming, that is why it's harder to find some ready and free solution.
I see nobody answered the sub question.
some way to use a lemmatizer in another language (python NLTK, for instance?) in a PHP webapp
The php has at least exec and calls alike. One can simply run any external script or app.
there are some "lemmatizers" in php that could be found in internet, but at a quick check these are turn to be are "stemmers".
Make sure, Stemming won't do for you. Make sure the solution you already have in mind in other language is a Lemmatizer.
I suspect all solution that close to this naming would be in C-like languages. In case those are Open source or provided as libs you could build them into PHP as an extension.

PHP Syllable Detection [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I would like to find a way to be able to split a word into syllables with PHP. For example, the word "nevermore" ran through detect_syllables(), would return "nev-er-more." Are there any good APIs or something out there?
There's a useful PHd thesis paper by Frank Liang that describes an exceptionally accurate algorithm for this: written over 25 years ago, it's still valid. But I'm not aware of any implementation in PHP
EDIT
A quick google has identified this link to a Text Statistics library in PHP, which includes algorithms for syllable counting within words (among other readability measuring algorithms). You should be able to find the code for syllable splitting here.
I'm actually in the finishing stages of making a PHP Hyphenator class based upon Frank Liang's algorithm and the TeX dictionaries, which pretty much seems to be the appoach taken by all office suites. (Actually I found this topic while looking for a good name for it that wasn't already taken). With slowly improving support from browsers for the ­ entity, it's becoming a realistic option to hyphenate content in websites.
Core functionality is working; splitting (and thus counting) and/or hyphenating text and/or HTML, parsing TeX hyphen dictionaries, caching those parsed dictionaries. Some planned features are still missing but nothing that stops you from using it. Also there's no good documentation, samples, formal unittest or vanity site yet.
I've created a github site for it here and will post the current version on it ASAP, so check back in a few days.
I've only tested it with Dutch (my native language) and US English, so it may still have some issues with languages using different character sets.
Note that Frank Liang's paper is on hyphenation, NOT on syllable detection. In addition, his thesis paper itself states that its success rate is around 89% for the dictionary he used, which is not going to be good enough for everyone. There really is no substitute for manually doing it for every single word it seems. It's not that efficient to have to require a complete one-to-one lookup table wordlist in order to do it, but these days storage space is far less expensive than CPU time anyways.
Perhaps someone might consider making a CAPTCHA-like service so that many users could be asked to provide the solution to every known word, with the results checked against each other, so that one person wouldn't have to do it all themselves. I'd hope the results would be released freely once complete.

Is there a tool that can transform a static SQL string into valid Drupal db query code? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I am wondering if there is some tool available, that will take as input a SQL command, and as output will return valid Drupal code that can be used in the Drupal Api?
EDIT
The idea is I have large, 25 lines of SQL commands ready to be used on the database. And they are somehow complicated, so I am wondering how could I rewrite them with a tool to use the object members on the db_query to do the same stuff as my large SQL command line.
i assume there's no such tools.
Just read:
sql coding conventions
http://drupal.org/writing-secure-code
This might save some time, depending on what you are trying to do with SQL.
http://drupal.org/project/views
Plain 'ol non-Drupal SQL will still work in db_query ... it's just not a best practice since the database API can't retool the SQL to work in any supported environment, and doesn't take advantage of Drupal's SQL injection protections, among other things.
But it still works.
If you're going to use the SQL in a known environment (e.g. a system where these commands are already in use), I'd say just use them as they are for now and gradually convert them over to Drupal standards as new code is developed.
(Of course, if this code is meant to be distributed to other environments, you'll want to put in sweat equity and convert the strings, or write a tool to do so)

Looking for an open source CMS with excellent internationalization and localization [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Can anyone suggest a CMS able to offer the following features:
Free/open source
Support for multiple languages (both frontend and backend)
Support for translating content (i.e. an article can have 1+ translations)
Support for different content types, namely pages, articles (timestamped, with comments) and image (galleries).
Support for basic categorization (just a level of sections is sufficient)
Support for media management (localizable image galleries)
User friendly
lightweight and fast
PHP or Ruby based
mature enough
Personally, I can only think of Drupal 6, but it's quite an overkill for what I want to do, and localization is not working 100%. I basically can live with anything which was built from the ground up with localization in mind.
After days of looking around and tryng out various demo site, SPIP seems to be the only proper solution to my problem. Any other idea?
Daisy was built from the ground-up with localization in mind.
In Daisy, each document can have one or more language variants, and Daisy tracks whether the source document and the translated variant are in-sync or not. This makes it very easy to manage change.
For example, I can ask Daisy 'Give me a list of documents for which either the Japanese translation doesn't exist, or it is not longer in sync with the original'. You can do this for any file type, including screenshots.
I think it hits all of your requirements except that it's built on the Java stack.
How about Joomla? I'm not sure if it fulfills all your requirements, but it's a suggestion nonetheless.
Probably under-kill, but WordPress with the qTranslate plugin works well for i18n of the admin interface plus the main content block of your page.

Learning PHP and web-programming for intermediate programmers [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I would like to know some good resources (book or website) on learning PHP for those who are already familiar with programming.
Many of the tutorials I've been finding are for people who never programmed before and take way to long to go through to even learn basic language constructs.
The optimal resource would not assume previous web-development background however.
The PHP Manual is what I used, especially with the search box in Firefox. Type in a function name and go. If you haven't already, it's probably worth browsing through while you wait for more answers.
Learning raw PHP is probably the wrong way to go if you're already an experienced programmer. I'd recommend picking up one of the frameworks, such as PHP Cake, Code Ignitor or Symfony. These frameworks attempt to enforce the set of best-practices that have developed for PHP developers over the past six or seven years.
To that end, Symfony has a great, "24 hours" style tutorial that can get you up and running with their framework, which will sneakily expose you to writing PHP code. Even if you decide you don't like symfony, concepts such as MVC, routing, templating, ORM, etc. will be covered. The other frameworks have similar tutorials, but I like the 24, one hour lessons approach.
For questions on specific PHP core functions/classes, php.net serves as a good resource (although the document of some of the core helper classes like XMLReader and the Reflection hierarchy can be sparse).
This site has some good stuff:
http://tizag.com
Whenever I am teaching anybody stuff I tell them to just Google "php [insert what you want to do]" and it will usually be in the first few results.
Another option:
http://php.net
Use http://www.w3schools.com. They've got a great tutorial for beginning and intermediate php programmers. Also, the PHP Manual is fantastic.
I definitely use the official site at php.net and O'Reilly's PHP Cookbook most often.
As well, the zend development zone, http://devzone.zend.com/public/view and
Manning's PHP in Action book are useful resources.
It's a bit old now, but I had a great learning experience with The PHP Anthology. If you check it out, please remember that it was published about 5 years ago.
A quick 'net search reveals there's a new one on the market as well, but I don't have experience with it.
Some free PHP5 e-books.
Practical PHP Programming
PHP 5 Objects, Patterns, and Practice
sounds nice
I strongly agree with #stalepretzel -- the w3schools and php.net sites are both incredibly rich resources for both getting you started and keeping you going.
For video tutorials (screencasts), you really can't beat "In the Woods - Diving into PHP" -- The first video is here: http://blog.themeforest.net/screencasts/diving-into-php-video-series/
Handy dandy quick ref here: http://www.addedbytes.com/cheat-sheets/php-cheat-sheet/
When/if you get stuck on a specific problem you can always come back here to SO.
Nicholas
What is your opinion about w3schools ? I recommend this website. This is suitable for beginners and advanced level too.
Also i would like to refer official PHP website and You Tube(Search Video related to PHP)

Categories